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 |
|---|---|---|---|---|---|---|
QPC004_A6 | A60CF20373DDB | 3 | AC | 2316 ms | 161 MiB | '''python
from qiskit import QuantumCircuit, QuantumRegister
from numpy import sqrt, acos
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
qc.swap(0, 1)
qc.ry(2 * acos(1 / sqrt(3)), 0)
qc.x(1)
qc.ch(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A6215EB78ED20 | 1 | AC | 1963 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(2*math.atan(math.sqrt(2)),1)
qc.ch(1,0)
qc.x(0)
qc.cx(0,1)
qc.x(0)
qc.cz(1,0)
return qc
''' |
QPC004_A6 | A6270302ABB84 | 1 | RE | 1687 ms | 157 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.x(1)
qc.ry(math.asin( sqrt(2)/sqrt(3) )*2, 0)
qc.cry(-math.pi/2, 0,1)
return qc
''' |
QPC004_A6 | A6270302ABB84 | 2 | RE | 1707 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(math.asin( sqrt(2)/sqrt(3) )*2, 0)
qc.cry(-math.pi/2, 0,1)
return qc
''' |
QPC004_A6 | A6270302ABB84 | 3 | RE | 1712 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(math.asin( sqrt(2)/sqrt(3) )*2, 0)
qc.ch(0,1)
qc.x(1)
qc.cx(1,0)
qc.x(1)
qc.cz(0,1)
return qc
''' |
QPC004_A6 | A6270302ABB84 | 4 | RE | 1719 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(math.asin( sqrt(2)/sqrt(3) )*2, 1)
qc.ch(1,0)
qc.x(0)
qc.cx(0,1)
qc.x(0)
qc.cz(0,1)
return qc
''' |
QPC004_A6 | A6270302ABB84 | 5 | WA | 1988 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(math.asin( math.sqrt(2)/math.sqrt(3) )*2, 0)
qc.ch(0,1)
qc.x(1)
qc.cx(1,0)
qc.x(1)
qc.cz(0,1)
return qc
''' |
QPC004_A6 | A6270302ABB84 | 6 | RE | 1840 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(math.asin( sqrt(2)/sqrt(3) )*2, 1)
qc.ch(1,0)
qc.x(0)
qc.cx(0,1)
qc.x(0)
qc.cz(0,1)
return qc
''' |
QPC004_A6 | A6270302ABB84 | 7 | AC | 1971 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(math.asin( math.sqrt(2)/math.sqrt(3) )*2, 1)
qc.ch(1,0)
qc.x(0)
qc.cx(0,1)
qc.x(0)
qc.cz(0,1)
return qc
''' |
QPC004_A6 | A65DEFD74A968 | 1 | RE | 1733 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
U = np.array([[1/np.sqrt(3), 1/np.sqrt(3), 1, 1],[0, 1/np.sqrt(3), 0, 0],[1/np.sqrt(3), 0, 0, 0],[-1/np.sqrt(3), 1/np.sqrt(3), 0, 0]])
qc.unitary(U, [0,1])
# theta1 = 2 * math.atan(math.sqrt(2))
# theta2 = 2 * math.atan(1)
# #00
# qc.x(0)
# qc.cry(theta1, 0, 1)
# qc.cry(theta2, 1, 0)
# qc.x(0)
return qc
''' |
QPC004_A6 | A66A9D6846D55 | 1 | RE | 1997 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
qc.h(0)
qc.u1(sqrt(3)/2, 1)
qc.cx(0, 1)
qc.x(0)
qc.h(1)
return qc
''' |
QPC004_A6 | A66A9D6846D55 | 2 | RE | 1580 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
qc.h(0)
qc.u1((3)^(1/2)/2, 1)
qc.cx(0, 1)
qc.x(0)
qc.h(1)
return qc
''' |
QPC004_A6 | A729C8233D0B5 | 1 | WA | 1823 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.h(0)
qc.cx(0, 1)
qc.x(0)
qc.cz(0, 1)
qc.x(0)
return qc
''' |
QPC004_A6 | A729C8233D0B5 | 2 | RE | 1637 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.h(0)
theta = 2 * np.arccos(np.sqrt(2/3))
qc.cry(theta, 0, 1)
qc.cz(0, 1)
return qc
''' |
QPC004_A6 | A729C8233D0B5 | 3 | WA | 1878 ms | 163 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.h(0)
theta = 2 * np.arccos(np.sqrt(2/3))
qc.cry(theta, 0, 1)
qc.cz(0, 1)
return qc
''' |
QPC004_A6 | A729C8233D0B5 | 4 | WA | 1846 ms | 160 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.h(0)
qc.cx(0, 1)
qc.x(0)
qc.cp(-np.pi/2, 0, 1) # Controlled phase gate
qc.x(0)
return qc
''' |
QPC004_A6 | A729C8233D0B5 | 5 | WA | 2637 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.h(0)
# Apply controlled gates to create the desired states
qc.cx(0, 1)
qc.h(1)
qc.cp(-np.pi, 0, 1) # Controlled phase gate for the -|11> term
qc.h(1)
return qc
''' |
QPC004_A6 | A729C8233D0B5 | 6 | WA | 1961 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.h(0)
qc.cx(0, 1)
qc.cp(np.pi, 0, 1)
qc.h(1)
return qc
''' |
QPC004_A6 | A77B1B3E99223 | 1 | AC | 1883 ms | 162 MiB | '''python
from qiskit import QuantumCircuit, QuantumRegister
import numpy as np
import math
def solve():
l, r = QuantumRegister(1), QuantumRegister(1)
qc = QuantumCircuit(l, r)
qc.ry(math.acos(math.sqrt(1 / 3)) * 2, r)
qc.ch(r, l)
qc.x(r)
qc.cx(l, r)
qc.cz(l, r)
return qc
''' |
QPC004_A6 | A9225E7859746 | 1 | WA | 1861 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(1.230, 0)
qc.rz(-0.785, 0)
qc.cx(0, 1)
qc.ry(0.628, 0)
qc.rz(2.111, 1)
qc.cx(0, 1)
qc.ry(-1.570, 0)
qc.rz(0.349, 0)
qc.cx(0, 1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 1 | RE | 1910 ms | 157 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(1/np.sqrt(3))
qc.ry(2*angle, 1)
qc.cx(1, 0)
qc.ch(1, 0)
qc.x(0)
qc.cx(0,1)
qc.x(0)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 2 | WA | 1841 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(1/np.sqrt(3))
qc.ry(2*angle, 1)
qc.cx(1, 0)
qc.ch(1, 0)
qc.x(0)
qc.cx(0, 1)
qc.x(0)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 3 | RE | 1742 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(1/np.sqrt(3))
qc.ry(2*angle, 0)
qc.cx(0, 1)
qc.ch(10, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 4 | WA | 2059 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(1/np.sqrt(3))
qc.ry(2*angle, 0)
qc.cx(0, 1)
qc.ch(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 5 | WA | 2027 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(1/np.sqrt(3))
qc.ry(2*angle, 1)
qc.cx(1, 0)
qc.ch(1, 0)
qc.x(0)
qc.cx(0, 1)
qc.x(0)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 6 | WA | 1744 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(1/2)
qc.ry(2*angle, 0)
qc.cx(0, 1)
qc.ch(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 7 | RE | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt{3})
qc.ry(2*angle, 0)
qc.cx(0, 1)
qc.ch(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' | ||
QPC004_A6 | A98E73B4E1DB7 | 8 | WA | 1722 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt(3))
qc.ry(2*angle, 0)
qc.cx(0, 1)
qc.ch(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 9 | WA | 1826 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt(3))
qc.ry(-2*angle, 0)
qc.cx(0, 1)
qc.ch(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 10 | WA | 2039 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt(3))
qc.ry(2*angle, 0)
qc.cx(0, 1)
qc.ch(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 11 | WA | 1884 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt(3))
qc.ry(2*angle, 1)
qc.cx(1, 0)
qc.ch(1, 0)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 12 | WA | 1649 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt(3))
qc.ry(2*angle, 1)
qc.cx(1, 0)
qc.ch(1, 0)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 13 | WA | 1849 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt(3))
qc.ry(2*angle, 1)
qc.cx(1, 0)
qc.ch(1, 0)
qc.x(0)
qc.cx(0, 1)
qc.x(0)
qc.cx(0,1)
qc.cx(1,0)
qc.cx(0,1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 14 | WA | 2298 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt(3))
qc.ry(2*angle, 0)
qc.cx(0, 1)
qc.ch(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 15 | WA | 1901 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt(3))
qc.ry(2*angle, 0)
qc.cx(0, 1)
qc.ch(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
qc.cx(0,1)
qc.cx(1,0)
qc.cx(0,1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 16 | WA | 1845 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt(3))
qc.ry(2*angle, 1)
qc.cx(1, 0)
qc.ch(1, 0)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
return qc
''' |
QPC004_A6 | A98E73B4E1DB7 | 17 | AC | 1714 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle=np.arcsin(np.sqrt(2)/np.sqrt(3))
qc.ry(2*angle, 1)
qc.cx(1, 0)
qc.ch(1, 0)
qc.x(0)
qc.cx(0, 1)
qc.x(0)
return qc
''' |
QPC004_A6 | A9A62A6F2C2CD | 1 | RE | 1713 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
# 定義するユニタリ行列 U (計算基底順序: |00>, |01>, |10>, |11>)
U = (1/np.sqrt(3)) * np.array([
[ 1, 1, 1, 0],
[ 1, -1, 0, 1],
[ 0, -1, 1, -1],
[-1, 0, 1, 1]
], dtype=complex)
# 2量子ビット全体に対して U を実装
qc.unitary(U, [0, 1], label="U")
return qc
''' |
QPC004_A6 | AAB2473C76F2F | 1 | WA | 1951 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.x(1)
qc.cx(1, 0)
qc.ch(0, 1)
qc.cx(1, 0)
qc.h(1)
qc.cx(1, 0)
qc.h(0)
return qc
''' |
QPC004_A6 | AAB2473C76F2F | 2 | WA | 1871 ms | 163 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.swap(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
qc.cx(1, 0)
qc.ch(0, 1)
qc.cx(1, 0)
qc.h(1)
qc.cx(1, 0)
qc.h(0)
return qc
''' |
QPC004_A6 | AAB2473C76F2F | 3 | WA | 1837 ms | 163 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.swap(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
qc.cry(2*np.arccos(2/3), 0, 1)
qc.cry(2*np.arccos(-1/np.sqrt(10)), 1, 0)
qc.ry(2*np.arccos(1/np.sqrt(3)), 1)
qc.cx(1, 0)
qc.ch(1, 0)
qc.cz(1, 0)
return qc
''' |
QPC004_A6 | AAB2473C76F2F | 4 | WA | 2003 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.swap(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
qc.cry(np.arccos(2/3), 0, 1)
qc.cry(np.arccos(-1/np.sqrt(10)), 1, 0)
qc.ry(np.arccos(1/np.sqrt(3)), 1)
qc.cx(1, 0)
qc.ch(1, 0)
qc.cz(1, 0)
return qc
''' |
QPC004_A6 | AAB2473C76F2F | 5 | WA | 1930 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.swap(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
qc.cry(2*np.arccos(2/3), 0, 1)
qc.cry(2*np.arccos(-1/np.sqrt(10)), 1, 0)
qc.ry(2*np.arccos(1/np.sqrt(3)), 1)
qc.ch(1, 0)
return qc
''' |
QPC004_A6 | AAB2473C76F2F | 6 | AC | 1999 ms | 163 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.swap(0, 1)
qc.swap(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
qc.cry(2*np.arccos(2/3), 0, 1)
qc.cry(2*np.arccos(-1/np.sqrt(10)), 1, 0)
qc.ry(2*np.arccos(1/np.sqrt(3)), 1)
qc.ch(1, 0)
qc.swap(0, 1)
return qc
''' |
QPC004_A6 | AABBAF707A884 | 1 | UME | '''python
from qiskit import QuantumCircuit, QuantumRegister
from math import pi, acos, sqrt, asin
from qiskit.circuit.library import XGate, ZGate, PhaseGate, CU1Gate, UnitaryGate
"""
You can apply oracle as follows:
qc.compose(o, inplace=True)
"""
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# qc.x(1)
x = sqrt(1/3)
gate = UnitaryGate([[x, x, 0, -x], [0, x, -x, x], [x, 0, x, x], [x, -x, -x, 0]], check_input=True)
qc.append(gate.inverse(), [0, 1])
return qc
''' | ||
QPC004_A6 | AABBAF707A884 | 2 | WA | 1983 ms | 161 MiB | '''python
from qiskit import QuantumCircuit, QuantumRegister
from math import pi, acos, sqrt, asin
from qiskit.circuit.library import XGate, ZGate, PhaseGate, CU1Gate
"""
You can apply oracle as follows:
qc.compose(o, inplace=True)
"""
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
"""
x = sqrt(1/3)
gate = UnitaryGate([[x, x, 0, -x], [0, x, -x, x], [x, 0, x, x], [x, -x, -x, 0]], check_input=True)
qc.append(gate.inverse(), [0, 1])
return qc.decompose(reps=1)
┌─────────────────────┐ ┌─────────────────┐ ┌────────────┐
q_0: ─┤ U(π,-1.7459,2.9665) ├───■──────┤ U(2.3005,0,π/2) ├───────■──────────┤ U(π/2,0,0) ├───────
┌┴─────────────────────┴┐┌─┴─┐┌───┴─────────────────┴────┐┌─┴─┐┌───────┴────────────┴──────┐
q_1: ┤ U(1.5256,2.68,1.4803) ├┤ X ├┤ U(1.4702,1.4692,-3.1314) ├┤ X ├┤ U(2.6678,-0.22308,2.9424) ├
└───────────────────────┘└───┘└──────────────────────────┘└───┘└───────────────────────────┘
"""
qc.u(pi, -1.7459, 2.9665, 0)
qc.u(1.5256, 2.68, 1.4803, 1)
qc.cx(0, 1)
qc.u(2.3005, 0, pi/2, 0)
qc.u(1.4702, 1.4692, -3.1314, 1)
qc.cx(0, 1)
qc.u(pi/2, 0, 0, 0)
qc.u(2.6678, -0.22308, 2.9424, 1)
return qc
''' |
QPC004_A6 | AABBAF707A884 | 3 | UME | '''python
from qiskit import QuantumCircuit, QuantumRegister
from math import pi, acos, sqrt, asin
from qiskit.circuit.library import XGate, ZGate, PhaseGate, CU1Gate
"""
You can apply oracle as follows:
qc.compose(o, inplace=True)
"""
def find_solution():
from qiskit.circuit.library import UnitaryGate
x = sqrt(1/3)
gate = UnitaryGate([[x, x, 0, -x], [0, x, -x, x], [x, 0, x, x], [x, -x, -x, 0]], check_input=True)
qc = QuantumCircuit(2)
qc.append(gate.inverse(), [0, 1])
qc = qc.decompose()
for gate in qc._data:
print(gate)
"""
┌─────────────────────┐ ┌─────────────────┐ ┌────────────┐
q_0: ─┤ U(π,-1.7459,2.9665) ├───■──────┤ U(2.3005,0,π/2) ├───────■──────────┤ U(π/2,0,0) ├───────
┌┴─────────────────────┴┐┌─┴─┐┌───┴─────────────────┴────┐┌─┴─┐┌───────┴────────────┴──────┐
q_1: ┤ U(1.5256,2.68,1.4803) ├┤ X ├┤ U(1.4702,1.4692,-3.1314) ├┤ X ├┤ U(2.6678,-0.22308,2.9424) ├
└───────────────────────┘└───┘└──────────────────────────┘└───┘└───────────────────────────┘
"""
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
qc.u(3.1415926535897927, -1.7459283308972953, 2.966460649487395, 0)
qc.u(1.5256421367586697, 2.679989861736903, 1.4803030618820676, 1)
qc.cx(0, 1)
qc.u(2.3005239830218636, 0.0, 1.5707963267948966, 0)
qc.u(1.4702087094713374, 1.4691752037207921, -3.1313531404558756, 1)
qc.cx(0, 1)
qc.u(pi/2, 0, 0, 0)
qc.u(2.6678334581465966, -0.22307720122877983, 2.9424024874858583, 1)
return qc
def test():
from qiskit.quantum_info import Statevector
qc = solve()
print(qc.depth())
sv = Statevector.from_instruction(qc)
print(sv)
print(sv.probabilities_dict())
''' | ||
QPC004_A6 | AABBAF707A884 | 4 | WA | 1911 ms | 161 MiB | '''python
from qiskit import QuantumCircuit, QuantumRegister
from math import pi, acos, sqrt, asin
from qiskit.circuit.library import XGate, ZGate, PhaseGate, CU1Gate
"""
You can apply oracle as follows:
qc.compose(o, inplace=True)
"""
def find_solution():
# from qiskit.circuit.library import UnitaryGate
x = sqrt(1/3)
gate = UnitaryGate([[x, x, 0, -x], [0, x, -x, x], [x, 0, x, x], [x, -x, -x, 0]], check_input=True)
qc = QuantumCircuit(2)
qc.append(gate.inverse(), [0, 1])
qc = qc.decompose()
for gate in qc._data:
print(gate)
"""
┌─────────────────────┐ ┌─────────────────┐ ┌────────────┐
q_0: ─┤ U(π,-1.7459,2.9665) ├───■──────┤ U(2.3005,0,π/2) ├───────■──────────┤ U(π/2,0,0) ├───────
┌┴─────────────────────┴┐┌─┴─┐┌───┴─────────────────┴────┐┌─┴─┐┌───────┴────────────┴──────┐
q_1: ┤ U(1.5256,2.68,1.4803) ├┤ X ├┤ U(1.4702,1.4692,-3.1314) ├┤ X ├┤ U(2.6678,-0.22308,2.9424) ├
└───────────────────────┘└───┘└──────────────────────────┘└───┘└───────────────────────────┘
"""
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
qc.u(3.1415926535897927, -1.7459283308972953, 2.966460649487395, 0)
qc.u(1.5256421367586697, 2.679989861736903, 1.4803030618820676, 1)
qc.cx(0, 1)
qc.u(2.3005239830218636, 0.0, 1.5707963267948966, 0)
qc.u(1.4702087094713374, 1.4691752037207921, -3.1313531404558756, 1)
qc.cx(0, 1)
qc.u(pi/2, 0, 0, 0)
qc.u(2.6678334581465966, -0.22307720122877983, 2.9424024874858583, 1)
return qc
def test():
# from qiskit.quantum_info import Statevector
qc = solve()
print(qc.depth())
sv = Statevector.from_instruction(qc)
print(sv)
print(sv.probabilities_dict())
''' |
QPC004_A6 | AACB3B6354E03 | 1 | WA | 1903 ms | 161 MiB | '''python
from math import acos
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
angle = 2 * acos(3 ** - 0.5)
qc.cry(angle, 0, 1)
qc.ch(1, 0)
return qc
''' |
QPC004_A6 | AB21B310AEB5A | 1 | AC | 1654 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import math
# from qiskit.quantum_info import Statevector
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.x(0)
qc.ry(math.acos(1/math.sqrt(3))*2, 1)
qc.ch(1, 0)
qc.x(0)
qc.cx(0, 1)
qc.x(0)
qc.swap(0, 1)
return qc
# if __name__ == "__main__":
# qc = solve()
# print(Statevector(qc))
''' |
QPC004_A6 | AB4E87B9491CA | 1 | RE | 1728 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
c0 = np.array([1, 1, 0, -1], dtype=complex) / math.sqrt(3)
c1 = np.array([-1, 2, 0, 1], dtype=complex) / math.sqrt(6)
c2 = np.array([1, 0, 1, 1], dtype=complex) / math.sqrt(3)
c3 = np.array([1, 0, -2, 1], dtype=complex) / math.sqrt(6)
U = np.column_stack([c0, c1, c2, c3])
gate = UnitaryGate(U, label="ZetaMoebius")
qc.append(gate, [0, 1])
return qc
''' |
QPC004_A6 | AB4E87B9491CA | 2 | UME | '''python
import math
import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit.library import UnitaryGate
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
c0 = np.array([1, 1, 0, -1], dtype=complex) / math.sqrt(3)
c1 = np.array([-1, 2, 0, 1], dtype=complex) / math.sqrt(6)
c2 = np.array([1, 0, 1, 1], dtype=complex) / math.sqrt(3)
c3 = np.array([1, 0, -2, 1], dtype=complex) / math.sqrt(6)
U = np.column_stack([c0, c1, c2, c3])
gate = UnitaryGate(U, label="ZetaMoebius")
qc.append(gate, [0, 1])
return qc
''' | ||
QPC004_A6 | AB4E87B9491CA | 3 | UME | '''python
import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit.library import UnitaryGate
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
c0 = np.array([1, 1, 0, -1], dtype=complex) / math.sqrt(3)
c1 = np.array([-1, 2, 0, 1], dtype=complex) / math.sqrt(6)
c2 = np.array([1, 0, 1, 1], dtype=complex) / math.sqrt(3)
c3 = np.array([1, 0, -2, 1], dtype=complex) / math.sqrt(6)
U = np.column_stack([c0, c1, c2, c3])
gate = UnitaryGate(U, label="ZetaMoebius")
qc.append(gate, [0, 1])
return qc
''' | ||
QPC004_A6 | AB4E87B9491CA | 4 | AC | 1857 ms | 161 MiB | '''python
import math
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
theta = 2 * math.atan(math.sqrt(2))
qc.ry(theta, 1)
qc.ch(1, 0)
qc.cz(1, 0)
qc.x(0)
qc.cx(0, 1)
qc.x(0)
return qc
''' |
QPC004_A6 | ABDC19E22EAB0 | 1 | AC | 1644 ms | 143 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
theta = math.atan(math.sqrt(2)) * 2
qc.ry(theta, 1)
qc.ch(1, 0)
qc.x(0)
qc.cx(0, 1)
qc.x(0)
qc.cz(0, 1)
return qc
''' |
QPC004_A6 | AC82D2EB8895B | 1 | AC | 2116 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(2*math.acos(math.sqrt(2/3)), 1)
qc.x(0)
qc.cx(1,0)
qc.x(1)
qc.ch(1,0)
qc.x(1)
qc.cx(0,1)
return qc
''' |
QPC004_A6 | ACFE380357E12 | 1 | RE | 1797 ms | 156 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(2 * math.atan(math.sqrt(2)), 1)
qc.ch(1, 0)
qc.x(0)
qc.cx(0, 1)
qc.x(0)
qc.cz(1, 0)
return qc
''' |
QPC004_A6 | ACFE380357E12 | 2 | RE | 1757 ms | 156 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(2 * math.atan(math.sqrt(2)), 1)
qc.ch(1, 0)
qc.x(0)
qc.cx(0, 1)
qc.x(0)
qc.cz(1, )
return qc
''' |
QPC004_A6 | ACFE380357E12 | 3 | AC | 1970 ms | 160 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(2 * math.atan(math.sqrt(2)), 1)
qc.ch(1, 0)
qc.x(0)
qc.cx(0, 1)
qc.x(0)
qc.cz(1, 0)
return qc
''' |
QPC004_A6 | AE182BD6CD638 | 1 | WA | 1822 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.h(0)
qc.z(1)
qc.s(1)
qc.x(0)
qc.h(0)
qc.cx(0, 1)
qc.s(0)
return qc
''' |
QPC004_A6 | AE182BD6CD638 | 2 | WA | 1973 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.h(0)
qc.z(1)
qc.s(0)
qc.x(0)
qc.h(0)
qc.cx(0, 1)
qc.s(0)
return qc
''' |
QPC004_A6 | AE182BD6CD638 | 3 | WA | 1882 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.h(0)
qc.z(1)
qc.x(0)
qc.h(0)
qc.cx(0, 1)
return qc
''' |
QPC004_A6 | AEA34DC7AA448 | 1 | RE | 1544 ms | 156 MiB | '''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.cp(2 * math.atan(math.sqrt(2)),1)
qc.ch(1,0)
qc.x(0)
qc.cx(0,1)
qc.x(0)
qc.cz(1,0)
return qc
''' |
QPC004_A6 | AEA34DC7AA448 | 2 | RE | 1555 ms | 156 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.cp(2 * math.atan(math.sqrt(2)),1)
qc.ch(1,0)
qc.x(0)
qc.cx(0,1)
qc.x(0)
qc.cz(1,)
return qc
''' |
QPC004_A6 | AEA34DC7AA448 | 3 | RE | 1520 ms | 156 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.cp(2 * math.atan(math.sqrt(2)),1)
qc.ch(1,0)
qc.x(0)
qc.cx(0,1)
qc.x(0)
qc.cz(1,0)
return qc
''' |
QPC004_A6 | AEA34DC7AA448 | 4 | AC | 1832 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
# Write your code here:
qc.ry(2 * math.atan(math.sqrt(2)),1)
qc.ch(1,0)
qc.x(0)
qc.cx(0,1)
qc.x(0)
qc.cz(1,0)
return qc
''' |
QPC004_A6 | AEB5FAA6C35C2 | 1 | AC | 2169 ms | 160 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
theta = 2 * np.arccos(1/np.sqrt(3))
qc.ry(theta, 1)
qc.ch(1,0)
qc.cx(0,1,ctrl_state=0)
qc.cz(1,0)
return qc
''' |
QPC004_A7 | A0147423327F7 | 1 | RE | 1465 ms | 141 MiB | '''python
from qiskit import QuantumCircuit
''' |
QPC004_A7 | A47DA57BAA61C | 1 | WA | 1885 ms | 163 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Write your code here:
return qc
''' |
QPC004_A7 | A47DA57BAA61C | 2 | WA | 1567 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import HGate, XGate, ZGate
import numpy as np
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Apply Hadamard gates to first n qubits to create uniform superposition
for i in range(n):
qc.h(i)
# Apply controlled-phase gates to implement the transformation
for i in range(n):
for j in range(i + 1, n):
qc.cp(np.pi / 4, i, j) # Controlled Phase to introduce subset relationships
# Apply Möbius transform (alternating sum effect)
for i in range(n):
qc.z(i) # Applying phase shift on first set
qc.cx(i, n + i) # XOR to second set of qubits
# Normalize by applying a global scaling factor (approximated with gates)
scale_factor = 1 / np.sqrt(3**n) # Scaling by 1/sqrt(3^n)
qc.rz(np.arcsin(scale_factor), range(n))
return qc
''' |
QPC004_A7 | A47DA57BAA61C | 3 | RE | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve(n: int) -> QuantumCircuit:
# Create circuit with 2n qubits
qc = QuantumCircuit(2 * n)
if n == 1:
# Apply Hadamard to create superposition
qc.h(0)
qc.h(1)
# Apply controlled phase rotations
qc.cp(np.pi/3, 0, 1)
# Apply additional gates for state transformation
qc.cx(0, 1)
qc.rz(np.pi/2, 1)
qc.h(0)
# Final adjustments
qc.cx(1, 0)
qc.h(1)
else:
# For n > 1, we construct generalized transformation
# Apply initial layer of Hadamards
for i in range(2*n):
qc.h(i)
# Apply controlled operations between pairs
for i in range(n):
qc.cp(np.pi/3, i, i+n)
# Apply mixing operations
for i in range(n-1):
qc.cx(i, i+1)
qc.cp(np.pi/4, i, i+n)
# Final layer of Hadamards
for i in range(2*n):
qc.h(i)
return qc
Last edited just now
''' | ||
QPC004_A7 | A47DA57BAA61C | 4 | WA | 1901 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve(n: int) -> QuantumCircuit:
# Create circuit with 2n qubits
qc = QuantumCircuit(2 * n)
if n == 1:
# For n=1, implement the exact transformation shown in sample
# Starting state: a₀|00⟩ + a₁|10⟩
# Target: 1/√3[(a₀ + a₁)|00⟩ + a₁|10⟩ + a₀|01⟩ - (a₀ - a₁)|11⟩]
# Create superposition
qc.ry(np.pi/3, 0) # Angle for 1/√3 factor
# Controlled operations
qc.cx(0, 1)
# Phase adjustment
qc.rz(np.pi, 1)
# Additional superposition
qc.ry(np.pi/4, 0)
qc.ry(np.pi/4, 1)
else:
# For n > 1, implement generalized transformation
for i in range(n):
# First layer: Create superpositions
qc.ry(np.pi/3, i)
# Second layer: Controlled operations
qc.cx(i, i+n)
# Third layer: Phase adjustments
qc.rz(np.pi/2, i+n)
if i < n-1: # Connect adjacent qubits except for last one
qc.cx(i, i+1)
return qc
''' |
QPC004_A7 | A47DA57BAA61C | 5 | WA | 1586 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve(n: int) -> QuantumCircuit:
# Create circuit with 2n qubits
qc = QuantumCircuit(2 * n)
if n == 1:
# Layer 1
qc.ry(np.pi/3, 0)
# Layer 2
qc.cx(0, 1)
# Layer 3
qc.rz(np.pi, 1)
qc.ry(np.pi/4, 0)
# Layer 4
qc.ry(np.pi/4, 1)
else:
# Layer 1 - Initial rotations in parallel
for i in range(n):
qc.ry(np.pi/3, i)
# Layer 2 - First set of CNOT in parallel
for i in range(0, n, 2):
if i+1 < n:
qc.cx(i, i+1)
# Layer 3 - Second set of CNOT in parallel
for i in range(1, n, 2):
if i+1 < n:
qc.cx(i, i+1)
# Layer 4 - Controlled operations between pairs
for i in range(n):
qc.cx(i, i+n)
return qc
''' |
QPC004_A7 | A47DA57BAA61C | 6 | WA | 1591 ms | 163 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve(n: int) -> QuantumCircuit:
# Create circuit with 2n qubits
qc = QuantumCircuit(2 * n)
if n == 1:
# Apply Hadamard to create superposition
qc.h(0)
qc.h(1)
# Apply controlled phase rotations
qc.cp(np.pi/3, 0, 1)
# Apply additional gates for state transformation
qc.cx(0, 1)
qc.rz(np.pi/2, 1)
qc.h(0)
# Final adjustments
qc.cx(1, 0)
qc.h(1)
else:
# For n > 1, we construct generalized transformation
# Apply initial layer of Hadamards
for i in range(2*n):
qc.h(i)
# Apply controlled operations between pairs
for i in range(n):
qc.cp(np.pi/3, i, i+n)
# Apply mixing operations
for i in range(n-1):
qc.cx(i, i+1)
qc.cp(np.pi/4, i, i+n)
# Final layer of Hadamards
for i in range(2*n):
qc.h(i)
return qc
''' |
QPC004_A7 | A47DA57BAA61C | 7 | WA | 1575 ms | 160 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
if n == 1:
# We need to transform: a₀|00⟩ + a₁|10⟩ to
# 1/√3[(a₀ + a₁)|00⟩ + a₁|10⟩ + a₀|01⟩ - (a₀ - a₁)|11⟩]
# Layer 1: First transformation
qc.ry(2 * np.arccos(1/np.sqrt(3)), 0)
# Layer 2: Create entanglement
qc.cx(0, 1)
# Layer 3: Additional rotations
qc.rz(np.pi, 1)
# Layer 4: Final adjustments
qc.ry(np.pi/2, 0)
qc.ry(np.pi/2, 1)
else:
# For general n > 1 case
# Layer 1: Initial rotations
for i in range(n):
qc.ry(2 * np.arccos(1/np.sqrt(3)), i)
# Layer 2: Create entanglement pattern
for i in range(0, n-1, 2):
qc.cx(i, i+1)
# Layer 3: Middle layer connections
for i in range(1, n-1, 2):
qc.cx(i, i+1)
# Layer 4: Connect to second register
for i in range(n):
qc.cx(i, i+n)
return qc
''' |
QPC004_A7 | A47DA57BAA61C | 8 | WA | 1564 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Apply Hadamard gates to the first n qubits
for i in range(n):
qc.h(i)
# Apply controlled operations to create the desired transformation
for i in range(n):
qc.cx(i, n + i)
qc.cz(i, n + i)
# Apply additional gates to achieve the required amplitudes and phases
for i in range(n):
qc.h(n + i)
qc.cx(i, n + i)
return qc
''' |
QPC004_A7 | A47DA57BAA61C | 9 | WA | 1668 ms | 163 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Step 1: Apply Hadamard gates to the first n qubits to create superposition
for i in range(n):
qc.h(i)
# Step 2: Implement the transformation for S ⊆ T ⊆ [n]
for i in range(n):
qc.cx(i, n + i) # Controlled-X gate to copy subset information
qc.cz(i, n + i) # Controlled-Z gate to introduce phase factors
# Step 3: Implement the transformation for T ⊆ S ⊆ [n] with phase factors
for i in range(n):
qc.h(n + i) # Hadamard gate on the second register
qc.cx(i, n + i) # Controlled-X gate to enforce subset conditions
# Step 4: Ensure the circuit depth does not exceed 8
# The above steps are designed to keep the depth within the limit
return qc
# Example usage:
n = 1
qc = solve(n)
print(qc)
''' |
QPC004_A7 | A47DA57BAA61C | 10 | WA | 2574 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Apply Hadamard gates to the first n qubits to create superposition
for i in range(n):
qc.h(i)
# Apply controlled operations to create the desired transformation
for i in range(n):
qc.cx(i, n + i)
qc.h(n + i)
# Apply phase gates to introduce the (-1)^(|S| - |T|) factor
for i in range(n):
qc.cz(i, n + i)
return qc
# Example usage:
# qc = solve(1)
# print(qc)
''' |
QPC004_A7 | A47DA57BAA61C | 11 | WA | 1687 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import numpy as np
def solve(n: int) -> QuantumCircuit:
# Create quantum circuit with 2*n qubits
qc = QuantumCircuit(2 * n)
# For n=1 case, we need to implement:
# a₀|00⟩ + a₁|10⟩ → 1/√3{(a₀ + a₁)|00⟩ + a₁|10⟩ + a₀|01⟩ - (a₀ - a₁)|11⟩}
if n == 1:
# First, create superposition with correct amplitudes
theta = np.arccos(1/np.sqrt(3))
qc.ry(2*theta, 0)
# Add controlled operations for the second qubit
qc.cx(0, 1)
qc.x(0)
qc.cz(0, 1)
qc.x(0)
# Adjust phases
qc.rz(np.pi, 1)
qc.cx(0, 1)
# For n>1, we extend the transformation according to the general formula
else:
# Add gates for higher n values following the same pattern
# but extended to more qubits according to the formula
for i in range(n):
qc.ry(2*np.arccos(1/np.sqrt(3)), i)
qc.cx(i, i+n)
return qc
''' |
QPC004_A7 | A47DA57BAA61C | 12 | WA | 1588 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
# Create quantum circuit with 2n qubits
qc = QuantumCircuit(2 * n)
if n == 1:
# Implement the transformation for n=1 case
# First, create superposition using Hadamard gates
qc.h(0)
qc.h(1)
# Apply controlled operations to achieve desired amplitudes
qc.cx(0, 1)
qc.rz(3.14159/2, 1) # Phase rotation
qc.cx(0, 1)
# Additional transformations to match required output state
qc.s(0)
qc.t(1)
# Final Hadamard layer to complete transformation
qc.h(0)
qc.h(1)
else:
# For n > 1, implement the general transformation
# First layer: Create initial superposition
for i in range(2*n):
qc.h(i)
# Middle layers: Implement controlled operations
for i in range(n):
qc.cx(i, i+n)
qc.rz(3.14159/3, i+n)
qc.cx(i, i+n)
# Final layer: Cleanup and normalization
for i in range(2*n):
qc.h(i)
return qc
''' |
QPC004_A7 | A53DCFE1533C9 | 1 | AC | 2486 ms | 162 MiB | '''python
from qiskit import QuantumCircuit, QuantumRegister
from numpy import sqrt, acos
def solve(n) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
for i in range(n):
qc.swap(i, i + n)
qc.ry(2 * acos(1 / sqrt(3)), i)
qc.x(i + n)
qc.ch(i, i + n)
qc.x(i + n)
qc.cx(i + n, i)
qc.x(i + n)
return qc
''' |
QPC004_A7 | A59D26C1912E2 | 1 | AC | 2049 ms | 160 MiB | '''python
import math
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
theta = 2 * math.atan(math.sqrt(2))
for i in range(n):
qc.ry(theta, i + n)
qc.ch(n + i, i)
qc.x(i)
qc.cx(i, n + i)
qc.x(i)
qc.cz(n + i, i)
return qc
''' |
QPC004_A7 | A6729B9FB9CB8 | 1 | RE | 1702 ms | 156 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Write your code here:
for i in range(n):
qc.ry(2 * math.atan(math.sqrt(2)), i + n)
qc.ch(i + n, i)
qc.x(i)
qc.cx(i, i + n)
qc.x(i)
qc.cz(i + n, i)
return qc
''' |
QPC004_A7 | A6729B9FB9CB8 | 2 | AC | 1908 ms | 160 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Write your code here:
for i in range(n):
qc.ry(2 * math.atan(math.sqrt(2)), i + n)
qc.ch(i + n, i)
qc.x(i)
qc.cx(i, i + n)
qc.x(i)
qc.cz(i + n, i)
return qc
''' |
QPC004_A7 | A906AFD8D91D8 | 1 | AC | 2009 ms | 163 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Write your code here:
for i in range(n):
qc.ry(2 * math.atan(math.sqrt(2)),i+n)
qc.ch(i+n,i)
qc.x(i)
qc.cx(i,i+n)
qc.x(i)
qc.cz(i+n,i)
return qc
''' |
QPC004_A7 | ABF2349A4A64C | 1 | RE | 2605 ms | 160 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# For n = 1, we have two qubits: q[0] for S and q[1] for the auxiliary state
if n == 1:
# Start with the state a_0 |00> + a_1 |10>
# Apply Hadamard to create superposition
qc.h(0) # Create superposition on the first qubit
# Apply controlled operations to create the required transformation
qc.cx(0, 1) # Control from qubit 0 to qubit 1
# Apply phase shifts to create the required amplitudes
qc.ry(math.pi / 3, 1) # Apply a rotation to the second qubit
# Apply a second controlled operation to create the negative amplitude
qc.cx(0, 1) # Control from qubit 0 to qubit 1 again
# Apply another rotation to adjust the phase
qc.ry(-math.pi / 3, 1) # Apply a rotation to the second qubit
# For n = 2, 3, 4, 5, we would extend this logic similarly
# However, for the sake of this example, we will only implement for n = 1
return qc
''' |
QPC004_A7 | AD323CDCDBD86 | 1 | RE | 1841 ms | 156 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Write your code here:
for i in range(n):
qc.ry(2*math.acos(math.sqrt(2/3)), n+i)
qc.x(i)
qc.cx(n+i,i)
qc.x(n+i)
qc.ch(n+i,i)
qc.x(n+i)
qc.cx(i,n+i)
return qc
''' |
QPC004_A7 | AD323CDCDBD86 | 2 | AC | 2032 ms | 161 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Write your code here:
for i in range(n):
qc.ry(2*math.acos(math.sqrt(2/3)), n+i)
qc.x(i)
qc.cx(n+i,i)
qc.x(n+i)
qc.ch(n+i,i)
qc.x(n+i)
qc.cx(i,n+i)
return qc
''' |
QPC004_A7 | AF0E08DDAFFEB | 1 | WA | 1965 ms | 158 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Write your code here:
for i in reversed(range(2*n-1)):
qc.cx(i, i+1)
qc.cx(i+1, i)
return qc
''' |
QPC004_A7 | AF10DE6C30D3F | 1 | AC | 2060 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Write your code here:
for i in range(n):
qc.ry(2 * math.atan(math.sqrt(2)), i + n)
qc.ch(i + n, i)
qc.x(i)
qc.cx(i, i + n)
qc.x(i)
qc.cz(i + n, i)
return qc
''' |
QPC004_A7 | AFC6E854A0F1E | 1 | WA | 1782 ms | 162 MiB | '''python
from qiskit import QuantumCircuit, QuantumRegister
import numpy as np
import math
def make_control(g, bit):
return g if bit == 0 else g.control(bit)
def solve(n: int) -> QuantumCircuit:
l = QuantumRegister(n)
r = QuantumRegister(n)
qc = QuantumCircuit(l, r)
theta = math.acos(math.sqrt(1 / 3)) * 2
qc.ry(theta, r)
for idx in range(n):
qc.ch(r[idx], l[idx])
for idx in range(n):
qc.cx(l[idx], r[idx])
qc.x(l)
for idx in range(n):
qc.swap(l[idx], r[idx])
qc.z(l)
return qc
''' |
QPC004_A7 | AFC6E854A0F1E | 2 | AC | 2120 ms | 163 MiB | '''python
from qiskit import QuantumCircuit, QuantumRegister
import numpy as np
import math
def make_control(g, bit):
return g if bit == 0 else g.control(bit)
def solve(n: int) -> QuantumCircuit:
l = QuantumRegister(n)
r = QuantumRegister(n)
qc = QuantumCircuit(l, r)
theta = math.acos(math.sqrt(1 / 3)) * 2
qc.ry(theta, r)
qc.z(l)
for idx in range(n):
qc.ch(r[idx], l[idx])
for idx in range(n):
qc.cx(r[idx], l[idx])
qc.x(r)
for idx in range(n):
qc.cx(l[idx], r[idx])
qc.z(l)
return qc
''' |
QPC004_A7 | AFF311CA54174 | 1 | AC | 2035 ms | 160 MiB | '''python
from qiskit import QuantumCircuit
import math
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(2 * n)
# Write your code here:
for _ in range(n):
qc.ry(2 * math.atan(math.sqrt(2)),_+n)
qc.ch(_+n,_)
qc.x(_)
qc.cx(_,_+n)
qc.x(_)
qc.cz(_+n,_)
return qc
''' |
QPC004_B1 | A00E61690AD66 | 1 | AC | 2151 ms | 160 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)
return qc
''' |
QPC004_B1 | A0305FFE45A74 | 1 | AC | 2523 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Apply Hadamard gate to all qubits
qc.h(range(n))
return qc
''' |
QPC004_B1 | A04349FE5C1F6 | 1 | AC | 2455 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(range(n))
return qc
''' |
QPC004_B1 | A07D6C961F8FC | 1 | AC | 2141 ms | 162 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
qc.h(range(n))
return qc
''' |
QPC004_B1 | A0CF484007A19 | 1 | AC | 2469 ms | 160 MiB | '''python
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Apply Hadamard gate to each qubit
for qubit in range(n):
qc.h(qubit)
return qc
''' |
QPC004_B1 | A0E28BEADE1C6 | 1 | AC | 2139 ms | 163 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)
return qc
''' |
QPC004_B1 | A151E0526A5EB | 1 | WA | 1738 ms | 162 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)
return qc
''' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.