답안 #1054232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054232 2024-08-12T07:51:17 Z Ludissey Light Bulbs (EGOI24_lightbulbs) C++17
60.6022 / 100
277 ms 1204 KB
#include <bits/stdc++.h>
#include <signal.h>
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()

using namespace std;

int N, M, Q;
vector<vector<int>> grid;

void output(){
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << grid[i][j];
        }
        cout << "\n";
    }
}

int find_next(int l, int r){
    int c = 0;
    if(l == 0){
        c++;
        if(r == 1) c++;
    }
    return c;
}

signed main() {

    cin >> N;
    vector<int> pos(N);
    grid.resize(N, vector<int>(N, 0));

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) grid[i][j] = 1;
        cout << "?" << "\n";
        output();
        cout << flush;

        for (int j = 0; j < N; j++) grid[i][j] = 0;
        int base; cin >> base;

        if (base == N*N) {
            cout << "!" << "\n";
            for (int j = 0; j < N; j++) grid[i][j] = 1;
            output();
            cout << flush;
            return 0;
        }

        int l = 0, r = N-1;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            for (int j = l; j <= mid; j++) grid[i][j] = 1;
            cout << "?" << "\n";
            output();

            for (int j = 0; j < N; j++) grid[i][j] = 0;
            cout << flush;
            int res; cin >> res;

            if (res < (mid - l + 1) * N) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }

        int rnd = find_next(l, r);

        if (l == r) {
            pos[i] = l;
            continue;
        }
        if(i==0){
            grid[i][l] = 1;
            grid[i][r] = 1;
            cout << "?" << "\n";
            output();
            cout << flush;
            int res; cin >> res;
            if (res == N) {
                grid[i][l] = 0;
                grid[i][r] = 0;
                pos[i] = l;
                continue;
            }
            if (res == 2*N) {
                grid[i][l] = 0;
                grid[i][r] = 0;
                pos[i] = r+1;
                continue;
            }

            grid[i][rnd] = 1;
            cout << "?" << "\n";
            output();
            cout << flush;
            cin >> res;

            if (res == N*2 - 1) {
                grid[i][r] = 0;
                cout << "?" << "\n";
                output();
                cout << flush;
                cin >> res;
                if (res == N*2 - 1) pos[i] = r; 
                else pos[i] = l;
            } else {
                grid[i][r] = 0;
                cout << "?" << "\n";
                output();
                cout << flush;

                cin >> res;
                if (res == N*2 - 1) pos[i] = l; 
                else pos[i] = r;
            }

            grid[i][rnd] = 0;
            grid[i][l] = 0;
        }else{
            grid[i][l] = 1;
            grid[i-1][pos[i-1]] = 1;
            cout << "?" << "\n";
            output();
            cout << flush;
            int res; cin >> res;
            grid[i][l] = 0;
            grid[i-1][pos[i-1]]=0;
            if (res == N*2) {
                pos[i] = l;
            }else{
                pos[i] = r;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        grid[i][pos[i]] = 1;
    }

    cout << "!" << "\n";
    cout << flush;
    output();
    cout << flush;
    return 0;
}
# 결과 실행 시간 메모리 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 596 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 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 368 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 428 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 0 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 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 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 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 1 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 1 ms 344 KB Output is correct
38 Correct 0 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 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 344 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 0 ms 344 KB Output is correct
48 Correct 0 ms 596 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 0 ms 344 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 1 ms 344 KB Output is correct
53 Correct 1 ms 344 KB Output is correct
54 Correct 0 ms 344 KB Output is correct
55 Correct 0 ms 344 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 1 ms 344 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 0 ms 344 KB Output is correct
18 Correct 1 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 1 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 1 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 1 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 1 ms 344 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Partially correct 222 ms 1204 KB Partially correct
60 Correct 1 ms 344 KB Output is correct
61 Partially correct 208 ms 344 KB Partially correct
62 Partially correct 206 ms 496 KB Partially correct
63 Partially correct 224 ms 520 KB Partially correct
64 Partially correct 208 ms 344 KB Partially correct
65 Partially correct 237 ms 708 KB Partially correct
66 Partially correct 215 ms 344 KB Partially correct
67 Partially correct 225 ms 704 KB Partially correct
68 Partially correct 277 ms 592 KB Partially correct
69 Partially correct 206 ms 344 KB Partially correct
70 Partially correct 237 ms 344 KB Partially correct
71 Partially correct 196 ms 344 KB Partially correct
72 Correct 1 ms 344 KB Output is correct
73 Partially correct 91 ms 344 KB Partially correct
74 Partially correct 120 ms 340 KB Partially correct
75 Partially correct 204 ms 344 KB Partially correct
76 Partially correct 204 ms 344 KB Partially correct
77 Partially correct 189 ms 496 KB Partially correct
78 Partially correct 58 ms 344 KB Partially correct
79 Partially correct 202 ms 344 KB Partially correct
80 Partially correct 238 ms 936 KB Partially correct
81 Partially correct 208 ms 344 KB Partially correct
82 Partially correct 274 ms 728 KB Partially correct
83 Partially correct 205 ms 344 KB Partially correct
84 Partially correct 239 ms 344 KB Partially correct
85 Partially correct 222 ms 340 KB Partially correct
86 Partially correct 204 ms 592 KB Partially correct
87 Partially correct 232 ms 984 KB Partially correct
88 Partially correct 205 ms 344 KB Partially correct
89 Partially correct 198 ms 784 KB Partially correct
90 Partially correct 207 ms 344 KB Partially correct
91 Partially correct 213 ms 344 KB Partially correct
92 Partially correct 235 ms 344 KB Partially correct
93 Partially correct 249 ms 340 KB Partially correct
94 Partially correct 214 ms 496 KB Partially correct
95 Partially correct 214 ms 344 KB Partially correct
96 Partially correct 260 ms 496 KB Partially correct
97 Correct 0 ms 344 KB Output is correct