| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1346735 | phamngocphuc2008 | Light Bulbs (EGOI24_lightbulbs) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
using Grid = vector<vector<int>>;
int query(Grid grid)
{
cout << '?' << endl;
for(auto i : grid)
{
for(auto j : i) cout << j;
cout << endl;
}
int x;
cin >> x;
return x;
}
void answer(Grid grid)
{
cout << '!' << endl;
for(auto i : grid)
{
for(auto j : i) cout << j;
cout << endl;
}
}
int main()
{
int n;
cin >> n;
Grid ans(n, vector<int>(n));
for(int i = 0; i < n; ++i)
{
int l = 1;
int r = n+1;
while(l < r)
{
Grid ask(n, vector<int>(n));
int m = (l+r)/2;
if(m == 1)
{
for(int j = 0; j < n; ++j) give_line[i][j] = 1;
int num_straight = query(give_line);
for(int j = 1; j < n; ++j) ask[i][j] = 1;
int res = query(ask);
if(res == (n-1)*n || res == num_straight)
{
l = 1;
break;
}
else l=2;
}
else
{
for(int j = 0; j < m; ++j) ask[i][j] = 1;
int res = query(ask);
if(res == m*n) l=m+1;
else r = m;
}
}
--l;
//cerr << l << '\n';
if(l == n)
{
Grid line (n, vector<int>(n));
for(int j = 0; j < n; ++j) line[i][j] = 1;
answer(line);
return 0;
}
ans[i][l] = 1;
}
answer(ans);
}
