Submission #1151687

#TimeUsernameProblemLanguageResultExecution timeMemory
1151687Ghulam_JunaidLight Bulbs (EGOI24_lightbulbs)C++20
0 / 100
0 ms416 KiB
#include <bits/stdc++.h> using namespace std; const int N = 105; int n, mat[N][N]; int ask(pair<int, int> x, pair<int, int> y){ memset(mat, 0, sizeof mat); mat[x.first][x.second] = 1; mat[y.first][y.second] = 1; cout << "?" << endl; for (int i = 0; i < n; i ++){ for (int j = 0; j < n; j ++) cout << mat[i][j]; cout << endl; } int res; cin >> res; return res; } set<pair<int, int>> V, H; void solveV(){ int i = 0; int j = 0; auto I = *V.begin(); while (i < n and j < n){ if (V.find({i, j}) != V.end()){ j++; continue; } if (H.find({i, j}) != H.end()){ i++; continue; } int x = ask(I, {i, j}); if (x == 2 * n){ V.insert({i, j}); j++; } else{ H.insert({i, j}); i++; } } if (V.size() >= n){ memset(mat, 0, sizeof mat); cout << "!" << endl; for (auto [i, j] : V) mat[i][j] = 1; for (int i = 0; i < n; i ++){ for (int j = 0; j < n; j ++) cout << mat[i][j]; cout << endl; } } else{ memset(mat, 0, sizeof mat); cout << "!" << endl; for (auto [i, j] : H) mat[i][j] = 1; for (int i = 0; i < n; i ++){ for (int j = 0; j < n; j ++) cout << mat[i][j]; cout << endl; } } } void solveH(){ int i = 0; int j = 0; auto I = *H.begin(); while (i < n and j < n){ if (V.find({i, j}) != V.end()){ j++; continue; } if (H.find({i, j}) != H.end()){ i++; continue; } int x = ask(I, {i, j}); if (x == 2 * n){ H.insert({i, j}); i++; } else{ V.insert({i, j}); j++; } } if (V.size() >= n){ memset(mat, 0, sizeof mat); cout << "!" << endl; for (auto [i, j] : V) mat[i][j] = 1; for (int i = 0; i < n; i ++){ for (int j = 0; j < n; j ++) cout << mat[i][j]; cout << endl; } } else{ memset(mat, 0, sizeof mat); cout << "!" << endl; for (auto [i, j] : H) mat[i][j] = 1; for (int i = 0; i < n; i ++){ for (int j = 0; j < n; j ++) cout << mat[i][j]; cout << endl; } } } int main(){ cin >> n; int a = ask({0, 0}, {0, 1}); if (a == n){ H.insert({0, 0}); solveH(); return 0; } if (a == 2 * n){ V.insert({0, 0}); V.insert({0, 1}); solveV(); return 0; } int b = ask({0, 0}, {0, 2}); if (b == n){ H.insert({0, 0}); V.insert({0, 1}); solveV(); return 0; } if (b == 2 * n){ V.insert({0, 0}); V.insert({0, 2}); H.insert({0, 1}); solveV(); return 0; } int c = ask({0, 1}, {0, 2}); if (c == 0){ H.insert({0, 1}); V.insert({0, 0}); solveV(); return 0; } if (c == 2 * n){ V.insert({0, 1}); V.insert({0, 2}); H.insert({0, 0}); solveV(); return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...