結果
問題 | No.1896 Arrays and XOR Procedure 2 |
ユーザー | chineristAC |
提出日時 | 2022-04-08 22:06:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 108 ms / 2,000 ms |
コード長 | 2,413 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 78,720 KB |
最終ジャッジ日時 | 2024-05-06 07:39:10 |
合計ジャッジ時間 | 6,401 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
56,064 KB |
testcase_01 | AC | 50 ms
56,064 KB |
testcase_02 | AC | 48 ms
56,192 KB |
testcase_03 | AC | 85 ms
77,952 KB |
testcase_04 | AC | 99 ms
78,580 KB |
testcase_05 | AC | 99 ms
78,708 KB |
testcase_06 | AC | 86 ms
78,080 KB |
testcase_07 | AC | 107 ms
78,692 KB |
testcase_08 | AC | 97 ms
78,592 KB |
testcase_09 | AC | 98 ms
78,464 KB |
testcase_10 | AC | 100 ms
78,592 KB |
testcase_11 | AC | 101 ms
78,464 KB |
testcase_12 | AC | 99 ms
78,720 KB |
testcase_13 | AC | 96 ms
78,208 KB |
testcase_14 | AC | 94 ms
78,336 KB |
testcase_15 | AC | 94 ms
78,208 KB |
testcase_16 | AC | 93 ms
78,336 KB |
testcase_17 | AC | 94 ms
78,336 KB |
testcase_18 | AC | 80 ms
75,264 KB |
testcase_19 | AC | 65 ms
69,120 KB |
testcase_20 | AC | 99 ms
78,208 KB |
testcase_21 | AC | 67 ms
68,736 KB |
testcase_22 | AC | 108 ms
78,336 KB |
testcase_23 | AC | 99 ms
78,080 KB |
testcase_24 | AC | 98 ms
78,080 KB |
testcase_25 | AC | 99 ms
78,336 KB |
testcase_26 | AC | 100 ms
78,208 KB |
testcase_27 | AC | 104 ms
78,208 KB |
testcase_28 | AC | 87 ms
77,952 KB |
testcase_29 | AC | 83 ms
78,080 KB |
ソースコード
from collections import deque class Dinic: def __init__(self, N): self.N = N self.G = [[] for i in range(N)] def add_edge(self, fr, to, cap): forward = [to, cap, None] forward[2] = backward = [fr, 0, forward] self.G[fr].append(forward) self.G[to].append(backward) def add_multi_edge(self, v1, v2, cap1, cap2): edge1 = [v2, cap1, None] edge1[2] = edge2 = [v1, cap2, edge1] self.G[v1].append(edge1) self.G[v2].append(edge2) def bfs(self, s, t): self.level = level = [None]*self.N deq = deque([s]) level[s] = 0 G = self.G while deq: v = deq.popleft() lv = level[v] + 1 for w, cap, _ in G[v]: if cap and level[w] is None: level[w] = lv deq.append(w) return level[t] is not None def dfs(self, v, t, f): if v == t: return f level = self.level for e in self.it[v]: w, cap, rev = e if cap and level[v] < level[w]: d = self.dfs(w, t, min(f, cap)) if d: e[1] -= d rev[1] += d return d return 0 def flow(self, s, t): flow = 0 INF = 10**9 + 7 G = self.G while self.bfs(s, t): *self.it, = map(iter, self.G) f = INF while f: f = self.dfs(s, t, INF) flow += f return flow import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N = int(input()) A = li() B = li() for n in range(30)[::-1]: f = 0 for i in range(N): if A[i]>>n & 1 or B[i]>>n & 1: f = 1 if f: break res = [] for i in range(N): if A[i]>>n & 1: for j in range(N): if B[j]>>n & 1 == 0: res.append((2,i,j)) B[j] ^= A[i] break else: exit(print(0)) for i in range(N): if A[i]>>n & 1: res.append((1,i,0)) A[i] ^= B[0] print(len(res)) for t,i,j in res: print(t,i+1,j+1) assert max(A) < min(B)