Submission #1151690

#TimeUsernameProblemLanguageResultExecution timeMemory
1151690Ghulam_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 if (H.size() == n){ 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; } } else{ cout << 1 / 0 << 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 if (H.size() == n){ 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; } } else{ cout << 1 / 0 << 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; } }

Compilation message (stderr)

Main.cpp: In function 'void solveV()':
Main.cpp:75:19: warning: division by zero [-Wdiv-by-zero]
   75 |         cout << 1 / 0 << endl;
      |                 ~~^~~
Main.cpp: In function 'void solveH()':
Main.cpp:128:19: warning: division by zero [-Wdiv-by-zero]
  128 |         cout << 1 / 0 << endl;
      |                 ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...