# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
196896 |
2020-01-17T14:24:13 Z |
Juney |
Cave (IOI13_cave) |
C++14 |
|
867 ms |
640 KB |
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 5;
int chk(int arr[]) { return tryCombination(arr); }
int done, dc[MAXN], door[MAXN], ans[MAXN], sw[MAXN];
int one[MAXN], A[MAXN];
void f(int l, int r, int col) {
if(l == r) {
done++;
dc[done] = 1-col;
door[done] = l;
return;
}
int mid = l + r >> 1;
for(int i=0; i<l; i++) A[i] = 1-col;
for(int i=l; i<=mid; i++) A[i] = col;
for(int i=mid+1; i<=r; i++) A[i] = 1-col;
for(int i=0; i<=done; i++) A[door[i]] = dc[i];
if(chk(A) == done+1) f(l, mid, col);
else f(mid+1, r, col);
}
void exploreCave(int N) {
done = -1;
for(int i=0; i<N; i++) one[i] = 1;
for(int i=0; i<N; i++) {
for(int j=0; j<=done; j++) one[door[j]] = dc[j];
if(chk(one) == done+1) f(0, N-1, 1);
else f(0, N-1, 0);
}
for(int i=0; i<N; i++) ans[door[i]] = i;
for(int i=0; i<N; i++) sw[door[i]] = dc[i];
answer(sw, ans);
}
Compilation message
cave.cpp: In function 'void f(int, int, int)':
cave.cpp:19:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid = l + r >> 1;
~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
572 ms |
512 KB |
Output is correct |
2 |
Correct |
469 ms |
524 KB |
Output is correct |
3 |
Correct |
754 ms |
580 KB |
Output is correct |
4 |
Correct |
517 ms |
640 KB |
Output is correct |
5 |
Correct |
828 ms |
512 KB |
Output is correct |
6 |
Correct |
737 ms |
512 KB |
Output is correct |
7 |
Correct |
807 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
754 ms |
536 KB |
Output is correct |
13 |
Correct |
758 ms |
520 KB |
Output is correct |
14 |
Correct |
741 ms |
520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
794 ms |
512 KB |
Output is correct |
2 |
Correct |
6 ms |
408 KB |
Output is correct |
3 |
Correct |
741 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
5 |
Correct |
5 ms |
396 KB |
Output is correct |
6 |
Correct |
743 ms |
516 KB |
Output is correct |
7 |
Correct |
720 ms |
548 KB |
Output is correct |
8 |
Correct |
789 ms |
528 KB |
Output is correct |
9 |
Correct |
778 ms |
512 KB |
Output is correct |
10 |
Correct |
785 ms |
640 KB |
Output is correct |
11 |
Correct |
699 ms |
536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
396 KB |
Output is correct |
3 |
Correct |
5 ms |
332 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
396 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
6 ms |
512 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
396 KB |
Output is correct |
3 |
Correct |
5 ms |
332 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
396 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
6 ms |
512 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
512 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
5 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
512 KB |
Output is correct |
20 |
Correct |
113 ms |
516 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
512 KB |
Output is correct |
23 |
Correct |
104 ms |
472 KB |
Output is correct |
24 |
Correct |
114 ms |
512 KB |
Output is correct |
25 |
Correct |
106 ms |
516 KB |
Output is correct |
26 |
Correct |
5 ms |
512 KB |
Output is correct |
27 |
Correct |
6 ms |
384 KB |
Output is correct |
28 |
Correct |
113 ms |
512 KB |
Output is correct |
29 |
Correct |
5 ms |
452 KB |
Output is correct |
30 |
Correct |
114 ms |
476 KB |
Output is correct |
31 |
Correct |
114 ms |
472 KB |
Output is correct |
32 |
Correct |
6 ms |
384 KB |
Output is correct |
33 |
Correct |
5 ms |
512 KB |
Output is correct |
34 |
Correct |
5 ms |
384 KB |
Output is correct |
35 |
Correct |
109 ms |
472 KB |
Output is correct |
36 |
Correct |
117 ms |
460 KB |
Output is correct |
37 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
572 ms |
512 KB |
Output is correct |
2 |
Correct |
469 ms |
524 KB |
Output is correct |
3 |
Correct |
754 ms |
580 KB |
Output is correct |
4 |
Correct |
517 ms |
640 KB |
Output is correct |
5 |
Correct |
828 ms |
512 KB |
Output is correct |
6 |
Correct |
737 ms |
512 KB |
Output is correct |
7 |
Correct |
807 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
754 ms |
536 KB |
Output is correct |
13 |
Correct |
758 ms |
520 KB |
Output is correct |
14 |
Correct |
741 ms |
520 KB |
Output is correct |
15 |
Correct |
794 ms |
512 KB |
Output is correct |
16 |
Correct |
6 ms |
408 KB |
Output is correct |
17 |
Correct |
741 ms |
512 KB |
Output is correct |
18 |
Correct |
5 ms |
460 KB |
Output is correct |
19 |
Correct |
5 ms |
396 KB |
Output is correct |
20 |
Correct |
743 ms |
516 KB |
Output is correct |
21 |
Correct |
720 ms |
548 KB |
Output is correct |
22 |
Correct |
789 ms |
528 KB |
Output is correct |
23 |
Correct |
778 ms |
512 KB |
Output is correct |
24 |
Correct |
785 ms |
640 KB |
Output is correct |
25 |
Correct |
699 ms |
536 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
396 KB |
Output is correct |
28 |
Correct |
5 ms |
332 KB |
Output is correct |
29 |
Correct |
6 ms |
384 KB |
Output is correct |
30 |
Correct |
5 ms |
512 KB |
Output is correct |
31 |
Correct |
6 ms |
512 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
33 |
Correct |
5 ms |
384 KB |
Output is correct |
34 |
Correct |
5 ms |
396 KB |
Output is correct |
35 |
Correct |
5 ms |
512 KB |
Output is correct |
36 |
Correct |
6 ms |
512 KB |
Output is correct |
37 |
Correct |
5 ms |
384 KB |
Output is correct |
38 |
Correct |
5 ms |
384 KB |
Output is correct |
39 |
Correct |
6 ms |
384 KB |
Output is correct |
40 |
Correct |
5 ms |
512 KB |
Output is correct |
41 |
Correct |
5 ms |
384 KB |
Output is correct |
42 |
Correct |
5 ms |
512 KB |
Output is correct |
43 |
Correct |
5 ms |
512 KB |
Output is correct |
44 |
Correct |
5 ms |
512 KB |
Output is correct |
45 |
Correct |
113 ms |
516 KB |
Output is correct |
46 |
Correct |
5 ms |
384 KB |
Output is correct |
47 |
Correct |
5 ms |
512 KB |
Output is correct |
48 |
Correct |
104 ms |
472 KB |
Output is correct |
49 |
Correct |
114 ms |
512 KB |
Output is correct |
50 |
Correct |
106 ms |
516 KB |
Output is correct |
51 |
Correct |
5 ms |
512 KB |
Output is correct |
52 |
Correct |
6 ms |
384 KB |
Output is correct |
53 |
Correct |
113 ms |
512 KB |
Output is correct |
54 |
Correct |
5 ms |
452 KB |
Output is correct |
55 |
Correct |
114 ms |
476 KB |
Output is correct |
56 |
Correct |
114 ms |
472 KB |
Output is correct |
57 |
Correct |
6 ms |
384 KB |
Output is correct |
58 |
Correct |
5 ms |
512 KB |
Output is correct |
59 |
Correct |
5 ms |
384 KB |
Output is correct |
60 |
Correct |
109 ms |
472 KB |
Output is correct |
61 |
Correct |
117 ms |
460 KB |
Output is correct |
62 |
Correct |
5 ms |
384 KB |
Output is correct |
63 |
Correct |
477 ms |
528 KB |
Output is correct |
64 |
Correct |
481 ms |
640 KB |
Output is correct |
65 |
Correct |
826 ms |
512 KB |
Output is correct |
66 |
Correct |
536 ms |
520 KB |
Output is correct |
67 |
Correct |
796 ms |
640 KB |
Output is correct |
68 |
Correct |
756 ms |
540 KB |
Output is correct |
69 |
Correct |
771 ms |
552 KB |
Output is correct |
70 |
Correct |
5 ms |
384 KB |
Output is correct |
71 |
Correct |
5 ms |
512 KB |
Output is correct |
72 |
Correct |
722 ms |
532 KB |
Output is correct |
73 |
Correct |
729 ms |
532 KB |
Output is correct |
74 |
Correct |
750 ms |
536 KB |
Output is correct |
75 |
Correct |
738 ms |
512 KB |
Output is correct |
76 |
Correct |
6 ms |
512 KB |
Output is correct |
77 |
Correct |
5 ms |
384 KB |
Output is correct |
78 |
Correct |
805 ms |
516 KB |
Output is correct |
79 |
Correct |
767 ms |
512 KB |
Output is correct |
80 |
Correct |
867 ms |
532 KB |
Output is correct |
81 |
Correct |
794 ms |
512 KB |
Output is correct |
82 |
Correct |
822 ms |
512 KB |
Output is correct |
83 |
Correct |
718 ms |
512 KB |
Output is correct |
84 |
Correct |
5 ms |
512 KB |
Output is correct |
85 |
Correct |
115 ms |
504 KB |
Output is correct |
86 |
Correct |
740 ms |
640 KB |
Output is correct |
87 |
Correct |
5 ms |
384 KB |
Output is correct |
88 |
Correct |
5 ms |
384 KB |
Output is correct |
89 |
Correct |
113 ms |
384 KB |
Output is correct |
90 |
Correct |
96 ms |
476 KB |
Output is correct |
91 |
Correct |
97 ms |
504 KB |
Output is correct |
92 |
Correct |
782 ms |
512 KB |
Output is correct |
93 |
Correct |
806 ms |
640 KB |
Output is correct |
94 |
Correct |
815 ms |
520 KB |
Output is correct |
95 |
Correct |
6 ms |
512 KB |
Output is correct |
96 |
Correct |
6 ms |
384 KB |
Output is correct |
97 |
Correct |
738 ms |
548 KB |
Output is correct |
98 |
Correct |
109 ms |
476 KB |
Output is correct |
99 |
Correct |
745 ms |
512 KB |
Output is correct |
100 |
Correct |
6 ms |
460 KB |
Output is correct |
101 |
Correct |
123 ms |
516 KB |
Output is correct |
102 |
Correct |
112 ms |
516 KB |
Output is correct |
103 |
Correct |
740 ms |
512 KB |
Output is correct |
104 |
Correct |
6 ms |
384 KB |
Output is correct |
105 |
Correct |
5 ms |
384 KB |
Output is correct |
106 |
Correct |
6 ms |
512 KB |
Output is correct |
107 |
Correct |
114 ms |
472 KB |
Output is correct |
108 |
Correct |
116 ms |
476 KB |
Output is correct |
109 |
Correct |
808 ms |
528 KB |
Output is correct |
110 |
Correct |
759 ms |
512 KB |
Output is correct |
111 |
Correct |
6 ms |
420 KB |
Output is correct |