Submission #1053720

#TimeUsernameProblemLanguageResultExecution timeMemory
1053720SamAndLight Bulbs (EGOI24_lightbulbs)C++17
60.67 / 100
213 ms1032 KiB
#include <bits/stdc++.h> using namespace std; #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 102; int n; char b[N][N]; char a[N][N]; bool c[N][N]; map<vector<pair<int, int> >, int> mp; int qry(vector<pair<int, int> >& v) { sort(all(v)); if (mp.find(v) != mp.end()) return mp[v]; cout << '?' << endl; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if (binary_search(all(v), m_p(i, j))) cout << '1'; else cout << '0'; } cout << endl; } int ans = 0; /*memset(c, false, sizeof c); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if (binary_search(all(v), m_p(i, j))) { if (b[i][j] == 'H') { for (int j = 1; j <= n; ++j) c[i][j] = true; } else { for (int i = 1; i <= n; ++i) c[i][j] = true; } } } } for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) ans += c[i][j];*/ cin >> ans; return mp[v] = ans; } void solv() { cin >> n; //for (int i = 1; i <= n; ++i) // cin >> (b[i] + 1); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) a[i][j] = '0'; for (int i = 1; i <= n; ++i) { int l = 2, r = n; int u = n + 1; while (l <= r) { int m = (l + r) / 2; vector<pair<int, int> > v; for (int j = 1; j <= m; ++j) v.push_back(m_p(i, j)); if (qry(v) != m * n) { u = m; r = m - 1; } else l = m + 1; } if (u == n + 1) { cout << '!' << endl; for (int ii = 1; ii <= n; ++ii) { if (ii != i) { for (int j = 1; j <= n; ++j) cout << '0'; } else { for (int j = 1; j <= n; ++j) cout << '1'; } cout << endl; } return; } else { if (u >= 3) { a[i][u] = '1'; } else { vector<pair<int, int> > v; for (int j = 1; j <= 2; ++j) v.push_back(m_p(i, j)); if (qry(v) == n) { a[i][1] = '1'; } else { vector<pair<int, int> > v; for (int j = 1; j <= 3; ++j) v.push_back(m_p(i, j)); if (qry(v) == 2 * n - 1) { a[i][3] = '1'; } else { vector<pair<int, int> > v; v.push_back(m_p(i, 1)); v.push_back(m_p(i, 3)); if (qry(v) == n * 2) a[i][2] = '1'; else a[i][1] = '1'; } } } } } cout << '!' << endl; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { cout << a[i][j]; } cout << endl; } } int main() { #ifdef SOMETHING freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif // SOMETHING ios_base::sync_with_stdio(false), cin.tie(0); int tt = 1; //cin >> tt; while (tt--) { solv(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...