problem stringclasses 67
values | user stringlengths 13 13 | submission_order int64 1 57 | result stringclasses 10
values | execution_time stringlengths 0 8 | memory stringclasses 88
values | code stringlengths 47 7.62k |
|---|---|---|---|---|---|---|
QPC002_A4 | AEAE14E6F607C | 3 | WA | 1264 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1,n//2+1):
qc.cx(0,i)
for i in range(n//2+2,n):
qc.cx(n//2+1,i)
qc.z(0)
return qc
''' |
QPC002_A4 | AEAE14E6F607C | 4 | DLE | 1146 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1,n//2+1):
qc.cx(0,i)
for i in range(n//2+1,n):
qc.cx(0,i)
qc.z(0)
return qc
''' |
QPC002_A4 | AEAE14E6F607C | 5 | WA | 1284 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.cx(0, 1)
for i in range(2, n, 2):
if i + 1 < n:
qc.cx(i, i + 1)
qc.z(0)
return qc
''' |
QPC002_A4 | AEAE14E6F607C | 6 | DLE | 1616 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.cx(0, 1)
for i in range(1,n-1):
qc.cx(i, i + 1)
qc.z(0)
return qc
''' |
QPC002_A4 | AEAE14E6F607C | 7 | RE | 1152 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
for i in range(0,n,2):
qc.h(i)
qc.cx(i,i+1)
qc.z(i)
return qc
''' |
QPC002_A4 | AEAE14E6F607C | 8 | RE | 1145 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc.h(0)
step = 1
while step < n:
for i in range(step, n, 2*step):
qc.cx(0, i)
step *= 2
qc.z(0)
return qc
''' |
QPC002_A4 | AEAE14E6F607C | 9 | DLE | 1162 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(0)
step = 1
while step < n:
for i in range(step, n, 2*step):
qc.cx(0, i)
step *= 2
qc.z(0)
return qc
''' |
QPC002_A4 | AEAE14E6F607C | 10 | RE | 1176 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
for i in range(n):
qc.h(i)
for i in range(n):
qc.p(-3.141592653589793, i)
qc.append(QFT(num_qubits=n, inverse=True), range(n))
return qc
''' |
QPC002_A4 | AEAE14E6F607C | 11 | RE | 1070 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1,n//2+1):
qc.cx(0,i)
for i in range(n//2+1):
qc.cx(i,i+n//2)
if(n%2==1):
qc.cx(0,n)
qc.z(0)
return qc
''' |
QPC002_A4 | AEAE14E6F607C | 12 | AC | 2403 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1,n//2):
qc.cx(0,i)
for i in range(n//2):
qc.cx(i,i+n//2)
if(n%2==1):
qc.cx(0,n-1)
qc.z(0)
return qc
''' |
QPC002_A4 | AECCFACB117EF | 1 | DLE | 1532 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1,n):
qc.cx(0,i)
qc.z(1)
return qc
''' |
QPC002_A4 | AECCFACB117EF | 2 | DLE | 1176 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1,n):
qc.cx(0,i)
qc.z(n-1)
return qc
''' |
QPC002_A4 | AECCFACB117EF | 3 | DLE | 1214 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1,n):
qc.cx(0,i)
qc.z(n-1)
return qc
''' |
QPC002_A4 | AECCFACB117EF | 4 | WA | 1082 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(range(n))
for i in range(1,n):
qc.cx(0,i)
qc.z(n-1)
return qc
''' |
QPC002_A4 | AECCFACB117EF | 5 | WA | 1055 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(n-1):
qc.cx(i,i+1)
return qc
''' |
QPC002_A4 | AECCFACB117EF | 6 | DLE | 1154 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(n-1):
qc.cx(i,i+1)
qc.z(n-1)
return qc
''' |
QPC002_A4 | AECCFACB117EF | 7 | WA | 1096 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(n-1):
qc.cx(i,i+1)
qc.x(0)
return qc
''' |
QPC002_A4 | AECCFACB117EF | 8 | WA | 1397 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(range(n))
qc.x(range(n))
qc.h(range(n))
qc.z(n-1)
qc.h(range(n))
return qc
''' |
QPC002_A4 | AED53BD75897E | 1 | DLE | 1196 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.z(0)
for i in range(n - 1):
qc.cx(0, i + 1)
return qc
''' |
QPC002_A4 | AED53BD75897E | 2 | DLE | 1181 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.z(0)
for i in range(n - 1):
qc.cx(i, i + 1)
return qc
''' |
QPC002_A4 | AED53BD75897E | 3 | WA | 1162 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(n - 1):
qc.cz(i, i + 1)
return qc
''' |
QPC002_A4 | AED53BD75897E | 4 | WA | 1079 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
for i in range(n):
qc.h(i)
for i in range(n - 1):
qc.cz(i, n - 1)
return qc
''' |
QPC002_A4 | AED53BD75897E | 5 | DLE | 1240 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
for i in range(n - 1):
qc.h(i)
qc.x(n - 1)
for i in range(n - 1):
qc.cx(i, n - 1)
for i in range(n):
qc.h(i)
return qc
''' |
QPC002_A4 | AED53BD75897E | 6 | AC | 2880 ms | 142 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.z(0)
for i in range(1, n):
qc.cx(i // 2, i)
return qc
''' |
QPC002_A4 | AEFA450355619 | 1 | DLE | 1390 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1, n):
# entangle the states using cnot with 0 qubit as control
qc.cx(0, i)
# use z gate to phase flip the highest state
qc.z(0)
return qc
''' |
QPC002_A4 | AEFA450355619 | 2 | RE | 1372 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1, n):
# entangle the states using cnot with 0 qubit as control
qc.cx(0, i)
# use z gate to phase flip the highest state but use cz to decrease depth
qc.cz(0)
return qc
''' |
QPC002_A4 | AEFA450355619 | 3 | DLE | 1418 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1, n):
# entangle the states using cnot with 0 qubit as control
qc.cx(0, i)
# use z gate to phase flip the highest state but use cz to decrease dept
qc.cz(0, n-1)
return qc
''' |
QPC002_A4 | AEFA450355619 | 4 | RE | 1448 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1, n):
# entangle the states using cnot with 0 qubit as control
qc.cnot(0, i)
# use z gate to phase flip the highest state but use cz to decrease dept
qc.cz(0, n-1)
return qc
''' |
QPC002_A4 | AEFFE50ED2ECC | 1 | DLE | 1524 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.cx(0, range(1, n))
qc.cz(0, 1)
return qc
''' |
QPC002_A4 | AEFFE50ED2ECC | 2 | AC | 2088 ms | 142 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1, n):
qc.cx(i//2, i)
qc.cz(0, 1)
return qc
''' |
QPC002_A4 | AF11F56825EA6 | 1 | DLE | 1812 ms | 156 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for _ in range(1,n):
qc.cx(0,_)
qc.z(0)
return qc
''' |
QPC002_A4 | AF11F56825EA6 | 2 | WA | 1761 ms | 154 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.cx(0,1)
for i in range(1,(n - 1) // 2):
qc.cx(0,i * 2)
qc.cx(1,i * 2 + 1)
qc.z(0)
return qc
''' |
QPC002_A4 | AF11F56825EA6 | 3 | WA | 1753 ms | 154 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.cx(0,1)
for i in range(1,(n - 1) // 2):
qc.cx(0,i * 2)
qc.cx(1,i * 2 + 1)
if n % 2 == 1:
qc.cx(0,n - 1)
qc.z(0)
return qc
''' |
QPC002_A4 | AF11F56825EA6 | 4 | AC | 2150 ms | 157 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.cx(0,1)
for i in range(1,n // 2):
qc.cx(0,i * 2)
qc.cx(1,i * 2 + 1)
if n % 2 == 1:
qc.cx(0,n - 1)
qc.z(0)
return qc
''' |
QPC002_A4 | AF4198C186231 | 1 | DLE | 1368 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1, n):
qc.cx(0, i)
qc.cz(0, 1)
return qc
''' |
QPC002_A4 | AF7B7889E5503 | 1 | DLE | 1636 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.x(0)
qc.h(0)
for i in range(n - 1):
qc.cx(i, i + 1)
return qc
''' |
QPC002_A4 | AF7B7889E5503 | 2 | AC | 2035 ms | 142 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.x(0)
qc.h(0)
qc.cx(0, 1)
# Apply a series of CNOT gates
for i in range(n - 1):
if i + 2 < n:
qc.cx(i, i + 2)
else:
pass
return qc
''' |
QPC002_A4 | AFB638952CBFC | 1 | DLE | 1168 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.cx(0, range(1, n))
qc.z(0)
return qc
''' |
QPC002_A4 | AFB638952CBFC | 2 | WA | 1547 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for d in range(1, n):
for i in range(n):
if i + d < n:
qc.cx(i, i + d)
qc.z(0)
return qc
''' |
QPC002_A4 | AFB638952CBFC | 3 | AC | 2792 ms | 142 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
d = 1
while d < n:
for i in range(0, d):
if i + d < n:
qc.cx(i, i + d)
print(i, i + d)
d *= 2
qc.z(0)
return qc
# solve(15).draw('mpl').show()
''' |
QPC002_A4 | AFD9C3A68358D | 1 | DLE | 1310 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1, n):
qc.cx(0,i)
qc.z(n-1)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 1 | DLE | 1219 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates from the first qubit to each of the other qubits
for i in range(1, n):
qc.cx(0, i)
# Step 3: Apply Z gate to the first qubit to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 2 | QLE | 1273 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(4)
# Write your code here:
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates from the first qubit to each of the other qubits
for i in range(1, 4):
qc.cx(0, i)
# Step 3: Apply Z gate to the first qubit to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 3 | QLE | 1315 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(3)
# Write your code here:
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates from the first qubit to each of the other qubits
for i in range(1, 3):
qc.cx(0, i)
# Step 3: Apply Z gate to the first qubit to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 4 | DLE | 1215 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Apply Hadamard gate to the first qubit
qc.h(0)
# Apply CNOT gates from the first qubit to each of the other qubits in parallel
for i in range(1, n):
qc.cx(0, i)
# Apply Z gate to the first qubit to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 5 | DLE | 1196 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates between the first qubit and each of the other qubits
for i in range(1, n):
qc.cx(0, i)
# Step 3: Apply Z gate to the first qubit to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 6 | RE | 1312 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
qc.cx(0, 1)
qc.cx(0, 2)
qc.cx(0, 3)
# Step 3: Apply Z gate to the first qubit to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 7 | RE | 1353 ms | 142 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
qc.cx(0, 1)
qc.cx(0, 2)
qc.cx(0, 3)
qc.cx(0, 4)
# Step 3: Apply Z gate to the first qubit to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 8 | DLE | 1367 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply Z gate to the first qubit to introduce the phase
qc.z(0)
# Step 3: Apply a final CNOT gate between the first qubit and all others
for i in range(1, n):
qc.cx(0, i)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 9 | WA | 1297 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply Z gate to the first qubit to introduce the phase
qc.z(0)
# Step 3: Apply a final CNOT gate between the first qubit and all others
for i in range(1, n-1):
qc.cx(0, i)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 10 | DLE | 1148 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 3: Apply a final CNOT gate between the first qubit and all others
for i in range(1, n):
qc.cx(0, i)
# Step 2: Apply Z gate to the first qubit to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 11 | WA | 1359 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gate to all qubits
for i in range(n):
qc.h(i)
# Step 2: Apply X gate to all qubits (to prepare for the MCZ)
for i in range(n):
qc.x(i)
# Step 3: Apply a multi-controlled Z (MCZ) gate
qc.h(n-1) # Convert Z to X (as multi-controlled X is easier)
qc.mcx(list(range(n-1)), n-1) # Apply the multi-controlled X
qc.h(n-1) # Convert X back to Z
# Step 4: Apply X gate again to all qubits
for i in range(n):
qc.x(i)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 12 | WA | 1359 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gates to all qubits
for i in range(n):
qc.h(i)
# Step 2: Apply an X gate to the last qubit to ensure Z gate impacts the correct state
qc.x(n-1)
# Step 3: Apply Controlled-Z gate between first qubit and the last one
qc.cz(0, n-1)
# Step 4: Apply X gate to revert the last qubit to its original state
qc.x(n-1)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 13 | WA | 1123 ms | 139 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gates to all qubits
for i in range(n):
qc.h(i)
# Step 2: Apply an n-qubit controlled-Z gate (multi-controlled Z)
# Convert Z to X (since multi-controlled X is easier to apply)
qc.h(n-1)
qc.mcx(list(range(n-1)), n-1) # Multi-controlled X
qc.h(n-1)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 14 | DLE | 1143 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates to entangle the first qubit with all others
for i in range(1, n):
qc.cx(0, i)
# Step 3: Apply a Z gate to introduce the phase of -1
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 15 | WA | 1198 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
# Step 1: Apply Hadamard gate to all qubits
for i in range(n):
qc.h(i)
# Step 2: Apply controlled-Z gate with depth optimization
qc.cz(0, n-1) # This introduces the -1 phase to the |1...1> state
# Step 3: Apply X gates to qubits 1 to n-2 and then controlled-Z
for i in range(1, n-1):
qc.cx(i, n-1) # Entangles qubits sequentially
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 16 | DLE | 1667 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates to entangle the first qubit with all others
for i in range(1, n):
qc.cx(0, i)
# Step 3: Apply a Z gate to introduce the phase of -1
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 17 | RE | 1208 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates in a layered manner
for i in range(1, n//2):
qc.cx(0, i) # First half of CNOTs
for i in range(n//2, n):
qc.cx(1, i) # Second half of CNOTs
# Step 3: Apply a Z gate to introduce the phase of -1
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 18 | RE | 1182 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates in layers to reduce depth
# Layer 1
qc.cx(0, 1)
qc.cx(0, 2)
qc.cx(0, 4)
qc.cx(0, 8)
# Layer 2
qc.cx(1, 3)
qc.cx(1, 5)
qc.cx(2, 6)
qc.cx(2, 7)
# Layer 3
qc.cx(3, 9)
qc.cx(4, 10)
qc.cx(5, 11)
qc.cx(6, 12)
# Step 3: Apply a Z gate to introduce the phase of -1
qc.z(0)
# Step 3: Apply a Z gate to introduce the phase of -1
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 19 | RE | 1179 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
## Step 2: Apply CNOT gates in layers to reduce depth
# Layer 1: Apply CNOT from qubit 0 to qubits 1, 2, 4, 8
qc.cx(0, 1)
qc.cx(0, 2)
qc.cx(0, 4)
qc.cx(0, 8)
# Layer 2: Apply CNOTs from qubits 1 to 3, 2 to 5, 4 to 6, 8 to 10
qc.cx(1, 3)
qc.cx(2, 5)
qc.cx(4, 6)
qc.cx(8, 10)
# Layer 3: Apply CNOTs from qubits 3 to 7, 5 to 9, 6 to 11, 10 to 12
qc.cx(3, 7)
qc.cx(5, 9)
qc.cx(6, 11)
qc.cx(10, 12)
# Layer 4: Apply CNOTs from qubits 7 to 13, 9 to 14
qc.cx(7, 13)
qc.cx(9, 14)
# Step 3: Apply a Z gate to introduce the phase of -1
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 20 | RE | 1120 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
## Step 2: Apply CNOT gates in layers to reduce depth
# Layer 1: Apply CNOT from qubit 0 to qubits 1, 2, 4, 8
qc.cx(0, 1)
qc.cx(0, 2)
qc.cx(0, 4)
qc.cx(0, 8)
# Layer 2: Apply CNOTs from qubits 1 to 3, 2 to 5, 4 to 6, 8 to 10
qc.cx(1, 3)
qc.cx(2, 5)
qc.cx(4, 6)
qc.cx(8, 10)
# Layer 3: Apply CNOTs from qubits 3 to 7, 5 to 9, 6 to 11, 10 to 12
qc.cx(3, 7)
qc.cx(5, 9)
qc.cx(6, 11)
qc.cx(10, 12)
# Layer 4: Apply CNOTs from qubits 7 to 13, 9 to 14
qc.cx(7, 13)
qc.cx(9, 14)
# Step 3: Apply a Z gate to introduce the phase of -1
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 21 | WA | 1352 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates in a more parallelized manner
step = 1
while step < n:
for i in range(0, n, step * 2):
if i + step < n:
qc.cx(i, i + step)
step *= 2
# Step 3: Apply a Z gate to the first qubit
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 22 | WA | 1187 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates in layers to minimize depth
# First layer: CNOT from qubit 0 to all qubits that are powers of 2
for i in range(1, n):
if i & (i - 1) == 0: # This condition checks if 'i' is a power of 2
qc.cx(0, i)
# Second layer: CNOT from qubits already entangled in the first layer to others
for i in range(1, n):
if i & (i - 1) != 0 and i & (n // 2) == 0: # Skip the powers of 2
qc.cx(0, i)
# Step 3: Apply Z gate to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 23 | WA | 1388 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates in a divide-and-conquer approach
current_layer = list(range(1, n))
while len(current_layer) > 1:
next_layer = []
for i in range(0, len(current_layer), 2):
if i + 1 < len(current_layer):
qc.cx(current_layer[i], current_layer[i+1])
next_layer.append(current_layer[i+1])
else:
next_layer.append(current_layer[i])
current_layer = next_layer
# Apply final CNOT gate from qubit 0 to the last qubit in the chain
qc.cx(0, current_layer[0])
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 24 | WA | 1183 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates in parallel layers to reduce depth
step = 1
while step < n:
for i in range(0, n - step, step * 2):
qc.cx(i, i + step)
step *= 2
# Step 3: Apply a final CNOT gate to the last qubit
if step // 2 < n:
qc.cx(0, n - 1)
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 25 | WA | 1122 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates in layers to maximize parallelism
step = 2
while step < n:
for i in range(step, n, 2 * step):
qc.cx(0, i)
step *= 2
# Step 3: Apply Z gate to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 26 | DLE | 1422 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates in layers to maximize parallelism
step = 1
while step < n:
for i in range(step, n, 2 * step):
qc.cx(0, i)
step *= 2
# Step 3: Apply Z gate to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 27 | WA | 1408 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates in layers to maximize parallelism
step = 1
while step < n:
for i in range(step, n, 6 * step):
qc.cx(0, i)
step *= 2
# Step 3: Apply Z gate to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A4 | AFE00F96D78C8 | 28 | DLE | 1386 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Step 1: Apply Hadamard gate to the first qubit
qc.h(0)
# Step 2: Apply CNOT gates in layers to maximize parallelism
step = 1
while step < n:
for i in range(step, n, 2 * step):
qc.cx(0, i)
step *= 2
# Step 3: Apply Z gate to introduce the phase
qc.z(0)
return qc
''' |
QPC002_A5 | A002AC2791D6C | 1 | RE | 1628 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(1,n//4):
qc.cx(0,i*4)
for i in range(n//4):
qc.cx(i*4,i*4+n//8)
for i in range(n//8):
qc.cx(2*i,2*i+1)
qc.z(0)
return qc
''' |
QPC002_A5 | A002AC2791D6C | 2 | RE | 1091 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(n//2,n,n//2):
qc.cx(0,i)
for i in range(0,n,n//2):
qc.cx(i,i+n//4)
for i in range(0,n,n//4):
qc.cx(i,i+n//8)
qc.z(0)
return qc
''' |
QPC002_A5 | A002AC2791D6C | 3 | RE | 1119 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(0,n,n//2):
if(n//2>0):
qc.cx(0,i+n//2)
for i in range(0,n,n//2):
if(n//4>0):
qc.cx(i,i+n//4)
for i in range(0,n,n//4):
if(n//8>0):
qc.cx(i,i+n//8)
qc.z(0)
return qc
''' |
QPC002_A5 | A002AC2791D6C | 4 | RE | 1552 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(0,n,n):
if(n//2>0):
qc.cx(i,i+n//2)
for i in range(0,n,n//2):
if (n//4>0):
qc.cx(i,i+n//4)
for i in range(0,n,n//4):
if (n//8>0):
qc.cx(i,i+n//8)
qc.z(0)
return qc
''' |
QPC002_A5 | A002AC2791D6C | 5 | RE | 1345 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
for i in range(0,n,n):
if(n//2>0):
qc.cx(i,i+n//2)
for i in range(0,n,n//2):
if (n//4>0):
qc.cx(i,i+n//4)
for i in range(0,n,n//4):
if (n//8>0):
qc.cx(i,i+n//8)
qc.z(n-1)
return qc
''' |
QPC002_A5 | A002AC2791D6C | 6 | AC | 1902 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
cnt=0
for i in range(0,n):
for j in range(2**i):
if (j+2**i < n):
qc.cx(j,j+2**i)
qc.z(0)
return qc
''' |
QPC002_A5 | A01519F2C05A9 | 1 | AC | 1724 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qbit_list = list(range(1, n, 1))
done_list = [0]
is_done = False
while(True):
doing_list = []
for c in done_list:
if len(qbit_list)==0:
is_done = True
break
target = qbit_list.pop(0)
qc.cx(c, target)
doing_list.append(target)
if is_done:
break
done_list.extend(doing_list)
qc.z(0)
return qc
''' |
QPC002_A5 | A04579D0D766B | 1 | DLE | 1348 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(n//2-1)
qc.cx(n//2-1,n//2)
for i in range((n-2)//2+1):
if 0 <= n//2-2-i < n:
qc.cx(n//2-1,n//2-2-i)
if 0 <= n//2+i+1 < n:
qc.cx(n//2,n//2+i+1)
qc.z(0)
return qc
''' |
QPC002_A5 | A04579D0D766B | 2 | WA | 1241 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(n//2-1)
qc.cx(n//2-1,n//2)
if n <= 6:
for i in range((n-2)//2+1):
if 0 <= n//2-2-i < n:
qc.cx(n//2-1,n//2-2-i)
if 0 <= n//2+i+1 < n:
qc.cx(n//2,n//2+i+1)
else:
pass
qc.z(0)
return qc
''' |
QPC002_A5 | A04579D0D766B | 3 | RE | 1068 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(n//2-1)
qc.cx(n//2-1,n//2)
if n <= 8:
for i in range((n-2)//2+1):
if 0 <= n//2-2-i < n:
qc.cx(n//2-1,n//2-2-i)
if 0 <= n//2+i+1 < n:
qc.cx(n//2,n//2+i+1)
else:
pas
qc.z(0)
return qc
''' |
QPC002_A5 | A04579D0D766B | 4 | WA | 1597 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(n//2-1)
qc.cx(n//2-1,n//2)
if n <= 8:
for i in range((n-2)//2+1):
if 0 <= n//2-2-i < n:
qc.cx(n//2-1,n//2-2-i)
if 0 <= n//2+i+1 < n:
qc.cx(n//2,n//2+i+1)
else:
pass
qc.z(0)
return qc
''' |
QPC002_A5 | A04579D0D766B | 5 | WA | 1618 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(n//2-1)
qc.cx(n//2-1,n//2)
if n <= 10:
for i in range((n-2)//2+1):
if 0 <= n//2-2-i < n:
qc.cx(n//2-1,n//2-2-i)
if 0 <= n//2+i+1 < n:
qc.cx(n//2,n//2+i+1)
else:
pass
qc.z(0)
return qc
''' |
QPC002_A5 | A04579D0D766B | 6 | WA | 1756 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(n//2-1)
qc.cx(n//2-1,n//2)
if n <= 9:
for i in range((n-2)//2+1):
if 0 <= n//2-2-i < n:
qc.cx(n//2-1,n//2-2-i)
if 0 <= n//2+i+1 < n:
qc.cx(n//2,n//2+i+1)
else:
pass
qc.z(0)
return qc
''' |
QPC002_A5 | A04579D0D766B | 7 | RE | 1437 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
if n < 10:
qc.h(n//2-1)
qc.cx(n//2-1,n//2)
for i in range((n-2)//2+1):
if 0 <= n//2-2-i < n:
qc.cx(n//2-1,n//2-2-i)
if 0 <= n//2+i+1 < n:
qc.cx(n//2,n//2+i+1)
else:
qc.h(0)
qc.cx(0,7)
qc.cx(0,3)
if n >= 11:
qc.cx(7,11)
qc.cx(0,2)
qc.cx(3,5)
qc.cx(7,9)
if n >= 13:
qc.cx(11,13)
qc.cx(0,1)
qc.cx(3,4)
qc.cx(5,6)
qc.cx(7,8)
if n >= 10:
qc.cx(9,10)
if n >= 12:
qc.cx(11,12)
if n >= 14:
qc.cx(13,14)
qc.z(0)
return qc
''' |
QPC002_A5 | A04579D0D766B | 8 | AC | 2182 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
if n < 10:
qc.h(n//2-1)
qc.cx(n//2-1,n//2)
for i in range((n-2)//2+1):
if 0 <= n//2-2-i < n:
qc.cx(n//2-1,n//2-2-i)
if 0 <= n//2+i+1 < n:
qc.cx(n//2,n//2+i+1)
else:
qc.h(0)
qc.cx(0,7)
qc.cx(0,3)
if n > 11:
qc.cx(7,11)
qc.cx(0,2)
qc.cx(3,5)
qc.cx(7,9)
if n > 13:
qc.cx(11,13)
qc.cx(0,1)
qc.cx(3,4)
qc.cx(5,6)
qc.cx(7,8)
if n > 10:
qc.cx(9,10)
if n > 12:
qc.cx(11,12)
if n > 14:
qc.cx(13,14)
qc.z(0)
return qc
''' |
QPC002_A5 | A0ACCE45A7E36 | 1 | RE | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
end = 1
while end < n:
for left in range(end):
qc.cx(left, end)
end += 1
if end == n:
break
qc.z(0)
return qc
''' | ||
QPC002_A5 | A0ACCE45A7E36 | 2 | WA | 1449 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
l = int(np.ceil(np.log2(n)))
for m in range(l, 0, -1):
step = 2 ** m
half_step = 2 ** (m - 1)
for k in range(0, n, step):
if k + half_step < n:
qc.cx(k, k + half_step)
return qc
''' |
QPC002_A5 | A0ACCE45A7E36 | 3 | WA | 1185 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
l = int(np.ceil(np.log2(n)))
for m in range(l, 0, -1):
step = 2 ** m
half_step = 2 ** (m - 1)
for k in range(0, n, step):
if k + half_step < n:
qc.cx(k, k + half_step)
return qc
''' |
QPC002_A5 | A0ACCE45A7E36 | 4 | AC | 2037 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
l = int(np.ceil(np.log2(n)))
for m in range(l, 0, -1):
step = 2 ** m
half_step = 2 ** (m - 1)
for k in range(0, n, step):
if k + half_step < n:
qc.cx(k, k + half_step)
qc.z(0)
return qc
''' |
QPC002_A5 | A1929A17BCF09 | 1 | AC | 1722 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(0)
cur = 1
max = 1
while True:
for i in reversed(range(max)):
qc.cx(i, cur)
print(f'{i}->{cur}')
cur += 1
if cur >= n:
qc.z(0)
return qc
max += 1
''' |
QPC002_A5 | A197F4335A74B | 1 | AC | 2686 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(0)
i = 1
while i < n:
for j in range(i):
if i + j < n:
qc.cx(j, i + j)
i *= 2
qc.z(n - 1)
return qc
''' |
QPC002_A5 | A19B7D7B81F4E | 1 | AC | 2151 ms | 161 MiB | '''python
import math
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.x(0)
qc.h(0)
def rec(l, r):
if r - l <= 1:
return
m = (l + r) // 2
qc.cx(l, m)
rec(l, m)
rec(m, r)
rec(0, n)
# for i in range(1, n):
# qc.cx(0, i)
return qc
# if __name__ == "__main__":
# from qiskit.quantum_info import Statevector
# import numpy as np
# n = 15
# qc = solve(n)
# sv = Statevector(qc)
# print(sv)
# print(qc)
# print(f"{qc.depth() = }")
# # sv = Statevector.from_label('+++')
# # print(sv.evolve(qc))
''' |
QPC002_A5 | A1A33597D7EA7 | 1 | WA | 2084 ms | 160 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
circuitEnd = False
for i in range(1, 5):
for j in range(i):
if (j + i >= n):
circuitEnd = True
break
qc.cx(j, j + i)
if (circuitEnd):
break
qc.z(0)
return qc
''' |
QPC002_A5 | A1A33597D7EA7 | 2 | AC | 2332 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
circuitEnd = False
for i in [int(pow(2, x)) for x in range(0, 4)]:
for j in range(i):
if (j + i >= n):
circuitEnd = True
break
qc.cx(j, j + i)
if (circuitEnd):
break
qc.z(0)
return qc
''' |
QPC002_A5 | A1EED261A60E7 | 1 | DLE | 1217 ms | 140 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(0)
for i in range(1,n):
qc.cx(i//2,i)
qc.z(0)
return qc
''' |
QPC002_A5 | A1EED261A60E7 | 2 | DLE | 1158 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(0)
A=[None,0,0,0,0,0,1,1,1,1,2,2,2,3,3,3,4,4,5,6]
for i in range(1,n):
qc.cx(A[i],i)
qc.z(A[n])
return qc
''' |
QPC002_A5 | A1EED261A60E7 | 3 | DLE | 1339 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(0)
A=[None,0,0,0,0,0,1,1,1,1,2,2,2,3,3,3,4,4,5,7]
for i in range(1,n):
qc.cx(A[i],i)
qc.z(A[n])
return qc
''' |
QPC002_A5 | A1EED261A60E7 | 4 | AC | 2580 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(0)
A=[None,0,0,0,0,0,1,1,1,1,2,2,2,3,3,3,4,4,5,6]
for i in range(1,n):
qc.cx(A[i],i)
qc.z(A[n+1])
return qc
''' |
QPC002_A5 | A22824C351484 | 1 | AC | 2817 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
def dnc(qc: QuantumCircuit, l: int, r: int) -> None:
if l == r:
return
m = (l + 1 + r) // 2
qc.cx(l, m)
dnc(qc, l, m - 1)
dnc(qc, m, r)
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(0)
qc.z(0)
dnc(qc, 0, n - 1)
return qc
''' |
QPC002_A5 | A230C8FCB8D8B | 1 | RE | 1565 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(0)
qc.cx(0, n-1)
def halve(qc, i, j):
if i != j:
half = (i + j) // 2
if i != half:
qc.cx(i, half)
if (half + 1) != j:
qc.cx(j, half + 1)
return qc, half
return qc, None
qc, half = halve(qc, 0, n - 1)
qc, half1 = halve(qc, 0, half)
qc, half2 = halve(qc, half + 1, n - 1)
qc, _ = halve(qc, 0, half1)
qc, _ = halve(qc, half1 +1, half)
qc, _ = halve(qc, half + 1, half2)
qc, _ = halve(qc, half2 + 1, n - 1)
qc.z(0)
return qc
''' |
QPC002_A5 | A230C8FCB8D8B | 2 | AC | 1952 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(0)
qc.cx(0, n-1)
def halve(qc, i, j):
if i != j:
half = (i + j) // 2
if i != half:
qc.cx(i, half)
if (half + 1) != j:
qc.cx(j, half + 1)
return qc, half
return qc, None
qc, half = halve(qc, 0, n - 1)
if half:
qc, half1 = halve(qc, 0, half)
qc, half2 = halve(qc, half + 1, n - 1)
if half1:
qc, _ = halve(qc, 0, half1)
qc, _ = halve(qc, half1 +1, half)
if half2:
qc, _ = halve(qc, half + 1, half2)
qc, _ = halve(qc, half2 + 1, n - 1)
qc.z(0)
return qc
''' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.