# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1048348 |
2024-08-08T07:00:57 Z |
정민찬(#11037) |
Light Bulbs (EGOI24_lightbulbs) |
C++17 |
|
0 ms |
596 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
int N;
vector<vector<int>> qry;
void init() {
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
qry[i][j] = 0;
}
}
}
int ask() {
cout << "?\n";
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
cout << qry[i][j];
}
cout << '\n';
}
cout.flush();
int ret;
cin >> ret;
return ret;
}
void answer(vector<vector<int>> &ans) {
cout << "!\n";
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
cout << ans[i][j];
}
cout << '\n';
}
cout.flush();
exit(0);
}
int dnc(int s, int e, int row) {
if (s == e) {
int oth = (s == 0 ? N-1 : 0);
init();
qry[row][s] = 1;
qry[row][oth] = 1;
int ret = ask();
if (ret == 2*N) return -1;
return s;
}
int mid = s + e >> 1;
init();
for (int i=s; i<=mid; i++) {
qry[row][i] = 1;
}
int ret = ask();
if (ret == (mid-s+1) * N) {
return dnc(mid+1, e, row);
}
return dnc(s, mid, row);
}
int main() {
ios_base :: sync_with_stdio(false); cin.tie(NULL);
cin >> N;
vector<vector<int>> ans(N, vector<int>(N, 0));
qry.resize(N, vector<int>(N, 0));
for (int i=0; i<N; i++) {
int pos = dnc(0, N-1, i);
if (pos == -1) {
fill(ans.begin(), ans.end(), vector<int>(N, 0));
for (int j=0; j<N; j++) {
ans[i][j] = 1;
}
answer(ans);
}
ans[i][pos] = 1;
}
answer(ans);
}
Compilation message
Main.cpp: In function 'int dnc(int, int, int)':
Main.cpp:55:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
55 | int mid = s + e >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
356 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
The lamps do not light up the entire grid |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
596 KB |
The lamps do not light up the entire grid |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
The lamps do not light up the entire grid |
4 |
Halted |
0 ms |
0 KB |
- |