답안 #1048584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1048584 2024-08-08T08:31:29 Z 5시간 대회를 2시간으로 즐길 수 있다니 완전 럭키비키잖아~(#11095) Light Bulbs (EGOI24_lightbulbs) C++17
57.4444 / 100
438 ms 1152 KB
#include <bits/stdc++.h>
using namespace std;

int n;
int pos[100];
int arr[100][100];

int query() {
    printf("?\n");
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            printf("%d",arr[i][j]);
        }
        printf("\n");
    }
    fflush(stdout);
    int x;
    scanf("%d",&x);
    return x;
}

void answer() {
    printf("!\n");
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            printf("%d",arr[i][j]);
        }
        printf("\n");
    }
    fflush(stdout);
}

int solve(int x) {
    memset(arr,0,sizeof(arr));
    for(int i=0;i<n;i++) {
        arr[x][i]=true;
    }
    int got=query();
    if (query()==n*n) {
        answer();
        return -1;
    }
    int gv=(n*n-got)/(n-1);
    int lo=-1;
    int hi=n-1;
    while (lo+1<hi) {
        int mid=(lo+hi)/2;
        memset(arr,0,sizeof(arr));
        int got1;
        if (mid!=0) {
            for(int i=0;i<=mid;i++) {
                arr[x][i]=true;
            }
            if (query()==(mid+1)*n) {
                lo=mid;
            }
            else {
                hi=mid;
            }
        }
        else {
            for(int i=mid+1;i<n;i++) {
                arr[x][i]=1;
            }
            int val=(n-1-gv)*n+gv+1;
            if (query()!=val) {
                hi=mid;
            }
            else {
                lo=mid;
            }
        }
    }
    return hi;
}

int main(void) {
    scanf("%d",&n);
    bool flag=true;
    for(int i=0;i<n;i++) {
        int got=solve(i);
        if (got==-1) {
            return 0;
        }
        pos[i]=got;
    }
    memset(arr,0,sizeof(arr));
    for(int i=0;i<n;i++) {
        arr[i][pos[i]]=1;
    }
    answer();
}

Compilation message

Main.cpp: In function 'int solve(int)':
Main.cpp:49:13: warning: unused variable 'got1' [-Wunused-variable]
   49 |         int got1;
      |             ^~~~
Main.cpp: In function 'int main()':
Main.cpp:79:10: warning: unused variable 'flag' [-Wunused-variable]
   79 |     bool flag=true;
      |          ^~~~
Main.cpp: In function 'int query()':
Main.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d",&x);
      |     ~~~~~^~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:78:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 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 1 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 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 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 0 ms 384 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 1 ms 344 KB Output is correct
28 Correct 1 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 1 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 1 ms 344 KB Output is correct
36 Correct 1 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 1 ms 344 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 1 ms 344 KB Output is correct
45 Correct 0 ms 344 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 0 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 1 ms 344 KB Output is correct
52 Correct 1 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 1 ms 344 KB Output is correct
57 Correct 0 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 1 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 408 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 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 1 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 416 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 1 ms 340 KB Output is correct
28 Correct 1 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 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 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 344 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 1 ms 344 KB Output is correct
44 Correct 1 ms 344 KB Output is correct
45 Correct 1 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 1 ms 344 KB Output is correct
50 Correct 0 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 1 ms 344 KB Output is correct
54 Correct 1 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 344 KB Output is correct
58 Correct 1 ms 344 KB Output is correct
59 Partially correct 382 ms 472 KB Partially correct
60 Correct 2 ms 344 KB Output is correct
61 Partially correct 355 ms 700 KB Partially correct
62 Partially correct 352 ms 596 KB Partially correct
63 Partially correct 370 ms 900 KB Partially correct
64 Partially correct 403 ms 592 KB Partially correct
65 Partially correct 350 ms 344 KB Partially correct
66 Partially correct 353 ms 452 KB Partially correct
67 Partially correct 395 ms 476 KB Partially correct
68 Partially correct 366 ms 452 KB Partially correct
69 Partially correct 438 ms 480 KB Partially correct
70 Partially correct 358 ms 816 KB Partially correct
71 Partially correct 349 ms 344 KB Partially correct
72 Correct 2 ms 344 KB Output is correct
73 Partially correct 112 ms 344 KB Partially correct
74 Partially correct 192 ms 448 KB Partially correct
75 Partially correct 370 ms 676 KB Partially correct
76 Partially correct 362 ms 344 KB Partially correct
77 Partially correct 342 ms 820 KB Partially correct
78 Partially correct 82 ms 344 KB Partially correct
79 Partially correct 397 ms 716 KB Partially correct
80 Partially correct 346 ms 344 KB Partially correct
81 Partially correct 377 ms 832 KB Partially correct
82 Partially correct 345 ms 344 KB Partially correct
83 Partially correct 368 ms 472 KB Partially correct
84 Partially correct 424 ms 1152 KB Partially correct
85 Partially correct 365 ms 452 KB Partially correct
86 Partially correct 336 ms 664 KB Partially correct
87 Partially correct 386 ms 344 KB Partially correct
88 Partially correct 334 ms 592 KB Partially correct
89 Partially correct 356 ms 344 KB Partially correct
90 Partially correct 344 ms 844 KB Partially correct
91 Partially correct 324 ms 344 KB Partially correct
92 Partially correct 340 ms 344 KB Partially correct
93 Partially correct 371 ms 468 KB Partially correct
94 Partially correct 347 ms 680 KB Partially correct
95 Partially correct 327 ms 692 KB Partially correct
96 Partially correct 344 ms 452 KB Partially correct
97 Correct 0 ms 344 KB Output is correct