QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#565734#8470. Deep AbyssMIT Isn’t Training (Jiangqi Dai, Ziqian Zhong, Peter Zhou)#TL 79ms11964kbPython33.1kb2024-09-15 22:06:522024-09-15 22:06:53

Judging History

This is the latest submission verdict.

  • [2024-09-15 22:06:53]
  • Judged
  • Verdict: TL
  • Time: 79ms
  • Memory: 11964kb
  • [2024-09-15 22:06:52]
  • Submitted

answer

import copy
L = 128
class S:
    u: list[list[int]]
    def __init__(self, num = None):
        self.u = []
        if num is not None:
            self.u = [None] * L
            for w in range(L):
                if num&(1<<w):
                    self.u[w] = [0] * L + [1]
                else:
                    self.u[w] = [0] * (L+1)
    def __and__(self, num):
        p = copy.deepcopy(self)
        for w in range(L):
            if num&(1<<w):
                pass
            else:
                p.u[w] = [0] * (L+1)
        return p
    def __rand__(self, num):
        return self.__and__(num)
    def __or__(self, num):
        p = copy.deepcopy(self)
        for w in range(L):
            if num&(1<<w):
                p.u[w] = [0] * L + [1]
        return p
    def __ror__(self, num):
        return self.__or__(num)
    def __xor__(self, num):
        p = copy.deepcopy(self)
        if type(num) != S:
            num = S(num)
        for w in range(L):
            p.u[w] = [x^y for x,y in zip(p.u[w],num.u[w])]
        return p
    def __rxor__(self, num):
        return self.__xor__(num)
    def __lshift__(self, x):
        p = S(0)
        for w in range(L):
            if w+x<L: p.u[w+x]=self.u[w]
        return p
    def __rshift__(self, x):
        p = S(0)
        for w in range(L):
            if w-x>=0: p.u[w-x]=self.u[w]
        return p
    def __invert__(self):
        p = copy.deepcopy(self)
        for w in range(L):
            p.u[w][L] ^= 1
        return p
    
def X():
    u = S()
    for w in range(L):
        u.u.append([1 if s==w else 0 for s in range(L+1)])
    return u

x_ = X()
x0 = copy.deepcopy(x_)
def FIXX(W):
    if type(W)!=S:
        W = S(W)
    return W
while True:
    try:
        U = input()
        U = U.strip()
        assert U!=''
    except:
        break
    U = U.split(' ')
    UP = []
    for SS in range(len(U)):
        if (not any('0'<=P<='9' for P in U[SS])) and any('a'<=P<='z' for P in U[SS]):
            U[SS] = U[SS]+'_'
            UP.append(U[SS])
    for SS in UP:
        try:
            exec(SS)
        except:
            exec(f'{SS} = 0')
    U = ' '.join(U)
    exec(U)
    LL = UP[0]
    exec(f'{LL} = FIXX({LL})')
x = x0^x_   # make sure it's zero!
xx = copy.deepcopy(x)
S = 0
R = [0] * 128 + [1]
for i in range(L):
    J = -1
    for j in range(S,L):
        if x.u[j][i]:
            J=j
            break
    if J == -1:
        continue
    if J != S:
        x.u[J],x.u[S] = x.u[S],x.u[J]
    for u in range(0,L):
        if u!=S and x.u[u][i]:
            x.u[u] = [a^b for a,b in zip(x.u[u],x.u[S])]
    S += 1
for i in range(L):
    if not x.u[i][L]:
        continue
    out = -1
    for j in range(L):
        if x.u[i][j]:
            out = j
            break
    R[out] = 1
#print(x.u)
bad = 0
for a in xx.u:
    if sum(p*q for p,q in zip(a,R))%2:
        bad = 1
if bad:
    print(':(')
else:
    ans = 0
    for u in range(L):
        if R[u]: ans|=1<<u
    print('0x{:x}'.format(ans))

詳細信息

Test #1:

score: 100
Accepted
time: 30ms
memory: 11144kb

input:

x = x | 0x19260817

output:

0x19260817

result:

ok single line: '0x19260817'

Test #2:

score: 0
Accepted
time: 31ms
memory: 11240kb

input:

x = x ^ 0xdeadbeef

output:

:(

result:

ok single line: ':('

Test #3:

score: 0
Accepted
time: 79ms
memory: 11964kb

input:

y = ~x << 3
z = ~x >> 2
w = x & ~0xa
k = ~x ^ 0xc
k = k << 1
k = k >> 2
x = y ^ z
p = k ^ w
x = x ^ p

output:

0x9a83dcd41ee6a0f73507b9a83dcd41ef

result:

ok single line: '0x9a83dcd41ee6a0f73507b9a83dcd41ef'

Test #4:

score: 0
Accepted
time: 25ms
memory: 11104kb

input:

x = x | 0x1
x = x << 128

output:

0x0

result:

ok single line: '0x0'

Test #5:

score: -100
Time Limit Exceeded

input:

a = ~0x85522c8627b00dcca8fced5dd3a64c94 << 106
a = 0x5729d5527c42197253400fdf189d7efe ^ ~a
a = a << 100
a = ~a << 43
b = 0xac8fc62f86ad065e524cc53a43d0b6de
b = b | ~0xe3efc9deb90a9ad986dc134ce403b83d
b = ~b << 7
b = a ^ ~b
c = a >> 58
c = c << 110
c = c & ~0xe42400e7403aaf75fc20b521bc485f98
c = ~0x4...

output:


result: