Your solution is almost correct for solving the Test set 1
The only mistake you have made is in function *solve1()*

Because you want to represent each worker with the binary representation of 
the index, i.e. from *0* to *n-1*,
you should use 

*l = len(bin(n - 1).lstrip('0b'))*

to determine the number of query you need to send.
using *bin(n)* will give you length of *11* when n is *1024*
在2021年3月3日星期三 UTC-8 下午2:02:02<alfredom...@gmail.com> 写道:

> Hi! 
> I am new into coding competitions and have started trying to solve past 
> problems. I got no problem while solving 2019 Qualification Round problems 
> A, B and C, but when it comes to the problem D, even when it works when I 
> run it locally, google sends me a Runtime Error (RE), but I don't really 
> know why this happens and I would really appreciate if someone could help 
> me.
>
> I think the problem comes with the interactive part of the problem. Also I 
> want to notice that I know my solutions does not work for Test Set 2 since 
> I have not come with an answer for that, but for Test Set 1 it should work 
> fine, but as I said before I get an RE.
>
> Here is the code I use to trying solving it in Python 3:
> -------------------------------------------
> def solve1(n):
>     l = len(bin(n).lstrip('0b'))
>     inp = [''] * l
>     for i in range(n):
>         a = bin(i).lstrip('0b').zfill(n)
>         for j in range(l):
>             inp[j] += a[n-j-1]
>     
>     return inp , l
>
> def solve2(m,l):
>     a = [''] * len(m[0])
>     p = []
>     for i in range(len(m[0])):
>         for j in range(l):
>             a[i] += m[l-j-1][i]
>     for k in a:
>         p.append(int(k,2))
>     return p
>
> def get_values(n,a,b):
>     sol = []
>     for i in range(n):
>         if i not in a:
>             sol.append(i)
>             b -= 1
>             if b == 0:
>                 break
>     return sol
>
> def solve():
>     m = []
>     n, b, f = map(int, input().split())
>     inp , l = solve1(n)
>     for i in range(l):
>         print(inp[i] , flush = True)
>         m.append(str(input()))
>     p = solve2(m,l)
>     sol = get_values(n,p,b)
>     print(*sol , flush = True)
>     verdict = int(input())
> t = int(input()) 
>
> for _ in range(t):
>     solve() 
> ----------------------------------------------
>
> If someone knows why locally works with F = 10, but when I submit it to 
> Google I get the RE error I would be really happy. 
> Thanks in advance. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/6e953004-c241-45c6-8851-969e4f2e0cabn%40googlegroups.com.

Reply via email to