Submission #1058692

# Submission time Handle Problem Language Result Execution time Memory
1058692 2024-08-14T12:19:50 Z Zbyszek99 Light Bulbs (EGOI24_lightbulbs) C++17
57.4767 / 100
65 ms 1308 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace std;
//mt19937 mt;void random(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll rand(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;

int n;
int ans_[100][100];

int ask(vector<pii> v)
{
    string q = "?\n";
    set<pii> s;
    forall(it,v) s.insert(it);
    rep(i,n)
    {
        rep(j,n)
        {
            if(s.find({i,j}) == s.end())
            {
                q += '0';
            }
            else
            {
                q += '1';
            }
        }
        q += '\n';
    }
    cout << q;
    cout.flush();
    int ans;
    cin >> ans;
    cout.flush();
    return ans;
}

int check_seg(int i, int l, int r)
{
    vector<pii> v;
    rep2(j,l,r) v.pb({i,j});
    return ask(v);
}

void solve()
{
    cin >> n;
    cout.flush();
    rep(i,n)
    {
        if(check_seg(i,0,n-1) == n*n)
        {
            cout << "!\n";
            rep(i2,n)
            {
                rep(j,n)
                {
                    if(i2 == i) cout << "1";
                    else cout << "0";
                }
                cout << "\n";
            }
            cout.flush();
            return;
        }
    }
    vector<int> dont_know;
    pii ok = {-1,-1};
    rep(i,n)
    {
        int pocz = 0;
        int kon = n-1;
        int ans = -1;
        while(pocz <= kon)
        {
            int mid = (pocz+kon+1)/2;
            if(mid == 0)
            {
                ans = -1;
                dont_know.pb(i);
                break;
            }
            int a = check_seg(i,0,mid);
            if(a == n)
            {
                ans = mid;
                break;
            }
            if(a % n == 0)
            {
                pocz = mid+1;
            }
            else
            {
                kon = mid-1;
                ans = mid;
            }
        }
        if(ans != -1)
        {
            ok = {i,ans};
            ans_[i][ans] = 1;
        }
    }
    if(ok.ff == -1)
    {
        bool was_ = true;
        rep2(j,1,n-1)
        {
            if(ask({{0,0},{0,j}}) == n*2) was_ = false;
        }
        if(!was_)
        {
            ok = {0,1};
            ans_[0][1] = 1;
        }
        else
        {
            if(ask({{0,1},{0,2}}) == n)
            {
                ok = {0,1};
                ans_[0][1] = 1;
            }
            else
            {
                ok = {0,0};
                ans_[0][0] = 1;
            }
        }
    }
        forall(it,dont_know)
        {
            if(it == ok.ff) continue;
            if(ask({ok,{it,0}}) == n*2)
            {
                ans_[it][0] = 1;
            }
            else ans_[it][1] = 1;
        }
    string z = "!\n";
    rep(i,n)
    {
        rep(j,n)
        {
            if(ans_[i][j] == 1) z += '1';
            else z += '0';
        }
        z += '\n';
    }
    cout << z;
    cout.flush();
}

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //random();
    int t = 1;
 //   cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
# 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 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 440 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 0 ms 436 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 0 ms 344 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 0 ms 344 KB Output is correct
54 Correct 1 ms 344 KB Output is correct
55 Correct 0 ms 344 KB Output is correct
56 Correct 1 ms 344 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 1 ms 344 KB Output is correct
59 Correct 0 ms 344 KB Output is correct
# 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 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 0 ms 344 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 0 ms 344 KB Output is correct
54 Correct 0 ms 344 KB Output is correct
55 Correct 1 ms 344 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 0 ms 600 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Partially correct 13 ms 496 KB Partially correct
60 Correct 0 ms 344 KB Output is correct
61 Partially correct 42 ms 640 KB Partially correct
62 Partially correct 34 ms 1308 KB Partially correct
63 Partially correct 39 ms 636 KB Partially correct
64 Partially correct 44 ms 592 KB Partially correct
65 Partially correct 55 ms 488 KB Partially correct
66 Partially correct 48 ms 728 KB Partially correct
67 Partially correct 44 ms 692 KB Partially correct
68 Partially correct 65 ms 792 KB Partially correct
69 Partially correct 41 ms 484 KB Partially correct
70 Partially correct 42 ms 860 KB Partially correct
71 Partially correct 39 ms 552 KB Partially correct
72 Correct 1 ms 344 KB Output is correct
73 Correct 5 ms 472 KB Output is correct
74 Correct 5 ms 476 KB Output is correct
75 Partially correct 49 ms 488 KB Partially correct
76 Partially correct 39 ms 492 KB Partially correct
77 Partially correct 53 ms 492 KB Partially correct
78 Correct 2 ms 480 KB Output is correct
79 Partially correct 41 ms 676 KB Partially correct
80 Partially correct 14 ms 492 KB Partially correct
81 Partially correct 42 ms 480 KB Partially correct
82 Partially correct 42 ms 484 KB Partially correct
83 Partially correct 36 ms 496 KB Partially correct
84 Partially correct 39 ms 608 KB Partially correct
85 Partially correct 39 ms 624 KB Partially correct
86 Partially correct 26 ms 484 KB Partially correct
87 Partially correct 49 ms 508 KB Partially correct
88 Partially correct 19 ms 580 KB Partially correct
89 Partially correct 60 ms 1276 KB Partially correct
90 Partially correct 26 ms 496 KB Partially correct
91 Partially correct 18 ms 480 KB Partially correct
92 Partially correct 40 ms 492 KB Partially correct
93 Partially correct 37 ms 504 KB Partially correct
94 Partially correct 37 ms 492 KB Partially correct
95 Partially correct 31 ms 496 KB Partially correct
96 Partially correct 45 ms 636 KB Partially correct
97 Correct 0 ms 344 KB Output is correct