| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1346501 | retarde | Light Bulbs (EGOI24_lightbulbs) | C++20 | 108 ms | 612 KiB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define int long long
#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
const int mod = 1e9 + 7;
const int inf = INTMAX_MAX;
const bool tc = false;
int query(vvi &g) {
cout << "?\n";
for (auto &x : g) {
for (auto &y : x) cout << y;
cout << '\n';
}
cout.flush();
int x; cin >> x;
return x;
}
void answer(vvi &g) {
cout << "!\n";
for (auto &x : g) {
for (auto &y : x) cout << y;
cout << '\n';
}
cout.flush();
}
int n;
inline void solve() {
cin >> n;
vvi ans(n, vi(n));
vector<pii> ds;
for (int i = 0; i < n; i++) {
// iterate over columns
int lo = 0; int hi = n;
pii ch = {-1, -1};
while (hi > lo + 1) {
int mid = (lo + hi) / 2;
vvi g(n, vi(n));
for (int r = 0; r <= mid; r++) g[r][i]=1;
int c = query(g);
ch = max(ch, {mid+1, c});
if (c < (mid+1)*n) hi = mid;
else lo = mid;
}
// lo is the guy
if (hi == n) {
// no verticals, every horizontal
vvi tmp(n, vi(n));
for (int r = 0; r < n; r++) tmp[r][i] = 1;
answer(tmp);
return;
}
// cout << "h " << ch.fi << " " << ch.se << '\n';
if (hi != 1) ans[hi][i]=1;
else {
// brah
if (ch.fi <= 2) {
vvi tmp2(n, vi(n));
for (int r = 0; r < n; r++) tmp2[r][i]=1;
int k = query(tmp2);
ch = {n, k};
}
// check without the 1st
vvi tmp3(n, vi(n));
for (int r = 1; r < ch.fi; r++) tmp3[r][i]=1;
int k2 = query(tmp3);
int dlt = ch.se-k2;
// if its n, then dc
if (dlt < n - 1) {
ans[0][i] = 1;
} else {
ans[1][i] = 1;
}
}
}
// for (auto &x : ds) cout << x.fi << " " << x.se << '\n';
answer(ans);
}
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
signed main() {
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
//setIO();
int t = 1;
if (tc) {
cin >> t;
}
while (t--) {
solve();
}
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
