#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 110;
int n, gr[MAX_N][MAX_N];
int ask(vector<pair<int, int>> x)
{
for (auto [i, j] : x)
gr[i][j] = 1;
printf("?\n");
for (int j = 0; j < n; j++)
{
for (int k = 0; k < n; k++)
printf("%d", gr[j][k]);
printf("\n");
}
fflush(stdout);
for (auto [i, j] : x)
gr[i][j] = 0;
int z;
scanf("%d", &z);
return z;
}
void ans(vector<pair<int, int>> x)
{
for (auto [i, j] : x)
gr[i][j] = 1;
printf("!\n");
for (int j = 0; j < n; j++)
{
for (int k = 0; k < n; k++)
printf("%d", gr[j][k]);
printf("\n");
}
fflush(stdout);
}
void checkv(vector<pair<int, int>> d)
{
set<int> s;
vector<pair<int, int>> x;
for (auto [i, j] : d)
if (s.find(j) == s.end())
{
x.push_back({i, j});
s.insert(j);
}
int z = ask(x);
if (z == n * n)
ans(x),
exit(0);
}
void checkh(vector<pair<int, int>> d)
{
set<int> s;
vector<pair<int, int>> x;
for (auto [i, j] : d)
{
if (s.find(i) == s.end())
{
x.push_back({i, j});
s.insert(i);
}
}
int z = ask(x);
if (z == n * n)
{
ans(x);
exit(0);
}
}
signed main()
{
scanf("%d", &n);
vector<pair<int, int>> h, v;
v = {{0, 0}};
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (i == 0 && j == 0)
continue;
int z = ask({{0, 0}, {i, j}});
if (z == (2 * n - 1))
h.push_back({i, j});
else
v.push_back({i, j});
}
}
checkh(h);
checkh(v);
checkv(v);
checkv(h);
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int ask(std::vector<std::pair<int, int> >)':
Main.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | scanf("%d", &z);
| ~~~~~^~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:72:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
72 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |