• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Interactive GCJ a guest Apr 9th, 2020 137 in 307 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import copy
2. import sys
4.
6.     x = input()
7.     if x=='N':
8.         exit(0)
9.     return x
10.
11. def flip(B):
12.     for i in range(len(B)):
13.         if B[i] == '1':
14.             B[i] = '0'
15.         elif B[i] == '0':
16.             B[i] = '1'
17.
18. def solve():
19.     B = [None for i in range(b)]
20.     firstEqual,firstDifferent = -1,-1
21.     queries,i = 0,0
22.     while i < b//2:
23.         if queries>0 and queries%10==0:
24.             # check for flipped
25.             if firstEqual != -1:
26.                 print(str(firstEqual+1), flush=True)
27.                 queries += 1
29.                 if x != B[firstEqual]:
30.                     flip(B)
31.             # check reverse
32.             if firstDifferent != -1:
33.                 print(str(firstDifferent+1), flush=True)
34.                 queries += 1
36.                 if x != B[firstDifferent]:
37.                     B=B[::-1]
38.             continue
39.         if queries % 10 == 9:
40.             # dummy query because we read 2 by 2
41.             print(str(1), flush=True)
42.             queries += 1
44.             continue
45.         print(str(i+1), flush=True)
46.         queries += 1
48.         print(str(b-i), flush=True)
49.         queries += 1
51.         if B[i]==B[-i-1] and firstEqual == -1:
52.             firstEqual = i
53.         if B[i]!=B[-i-1] and firstDifferent == -1:
54.             firstDifferent = i
55.         i += 1
56.     print(''.join(B), flush=True)