#include "cave.h"
// #pragma GCC target("avx2")
#pragma GCC optimize("Ofast", "unroll-loops")
// #include <bits/extc++.h>
// using namespace __gnu_pbds;
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
mt19937 __gen = mt19937(__rd()); \
uniform_int_distribution<int> __dis(1, 1E8); \
auto rnd = bind(__dis, __gen)
const int maxn = 1E5 + 5;
// void answer(int S[], int D[]);
// int tryCombination(int S[]);
void exploreCave(int N) {
int ans[N], pls[N], tmp[N];
memset(ans, 0xff, sizeof(ans));
for (int i = 0; i < N; ++i) {
for (int j = 0; j < N; ++j) tmp[j] = ans[j] >= 0 ? ans[j] : 1;
int on = tryCombination(tmp);
int st = on > i or on == -1;
int lo = 0, hi = N-1, mi, ret;
while (lo < hi) {
mi = lo + hi >> 1;
for (int j = 0; j < N; ++j) tmp[j] = ans[j] >= 0 ? ans[j] : (j > mi) ^ st;
ret = tryCombination(tmp);
if (ret > i or ret == -1) hi = mi;
else lo = mi + 1;
}
pls[lo] = i;
ans[lo] = st;
}
answer(ans, pls);
}
Compilation message
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:49:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
mi = lo + hi >> 1;
~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
160 ms |
384 KB |
Output is correct |
2 |
Correct |
161 ms |
504 KB |
Output is correct |
3 |
Correct |
250 ms |
384 KB |
Output is correct |
4 |
Correct |
168 ms |
508 KB |
Output is correct |
5 |
Correct |
238 ms |
384 KB |
Output is correct |
6 |
Correct |
233 ms |
384 KB |
Output is correct |
7 |
Correct |
241 ms |
464 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
236 ms |
384 KB |
Output is correct |
13 |
Correct |
244 ms |
504 KB |
Output is correct |
14 |
Correct |
239 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
252 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
242 ms |
460 KB |
Output is correct |
7 |
Correct |
286 ms |
384 KB |
Output is correct |
8 |
Correct |
270 ms |
384 KB |
Output is correct |
9 |
Correct |
246 ms |
384 KB |
Output is correct |
10 |
Correct |
256 ms |
468 KB |
Output is correct |
11 |
Correct |
310 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
0 ms |
256 KB |
Output is correct |
13 |
Correct |
0 ms |
256 KB |
Output is correct |
14 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
0 ms |
256 KB |
Output is correct |
13 |
Correct |
0 ms |
256 KB |
Output is correct |
14 |
Correct |
0 ms |
256 KB |
Output is correct |
15 |
Correct |
1 ms |
256 KB |
Output is correct |
16 |
Correct |
0 ms |
256 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
19 |
Correct |
0 ms |
256 KB |
Output is correct |
20 |
Correct |
37 ms |
384 KB |
Output is correct |
21 |
Correct |
0 ms |
384 KB |
Output is correct |
22 |
Correct |
0 ms |
256 KB |
Output is correct |
23 |
Correct |
35 ms |
384 KB |
Output is correct |
24 |
Correct |
35 ms |
384 KB |
Output is correct |
25 |
Correct |
35 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
256 KB |
Output is correct |
27 |
Correct |
0 ms |
256 KB |
Output is correct |
28 |
Correct |
34 ms |
384 KB |
Output is correct |
29 |
Correct |
0 ms |
256 KB |
Output is correct |
30 |
Correct |
34 ms |
384 KB |
Output is correct |
31 |
Correct |
37 ms |
384 KB |
Output is correct |
32 |
Correct |
0 ms |
256 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
0 ms |
384 KB |
Output is correct |
35 |
Correct |
37 ms |
384 KB |
Output is correct |
36 |
Correct |
35 ms |
384 KB |
Output is correct |
37 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
160 ms |
384 KB |
Output is correct |
2 |
Correct |
161 ms |
504 KB |
Output is correct |
3 |
Correct |
250 ms |
384 KB |
Output is correct |
4 |
Correct |
168 ms |
508 KB |
Output is correct |
5 |
Correct |
238 ms |
384 KB |
Output is correct |
6 |
Correct |
233 ms |
384 KB |
Output is correct |
7 |
Correct |
241 ms |
464 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
236 ms |
384 KB |
Output is correct |
13 |
Correct |
244 ms |
504 KB |
Output is correct |
14 |
Correct |
239 ms |
504 KB |
Output is correct |
15 |
Correct |
237 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
252 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
19 |
Correct |
0 ms |
256 KB |
Output is correct |
20 |
Correct |
242 ms |
460 KB |
Output is correct |
21 |
Correct |
286 ms |
384 KB |
Output is correct |
22 |
Correct |
270 ms |
384 KB |
Output is correct |
23 |
Correct |
246 ms |
384 KB |
Output is correct |
24 |
Correct |
256 ms |
468 KB |
Output is correct |
25 |
Correct |
310 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
256 KB |
Output is correct |
27 |
Correct |
0 ms |
256 KB |
Output is correct |
28 |
Correct |
0 ms |
256 KB |
Output is correct |
29 |
Correct |
0 ms |
256 KB |
Output is correct |
30 |
Correct |
1 ms |
256 KB |
Output is correct |
31 |
Correct |
0 ms |
256 KB |
Output is correct |
32 |
Correct |
1 ms |
256 KB |
Output is correct |
33 |
Correct |
0 ms |
256 KB |
Output is correct |
34 |
Correct |
0 ms |
256 KB |
Output is correct |
35 |
Correct |
1 ms |
384 KB |
Output is correct |
36 |
Correct |
0 ms |
256 KB |
Output is correct |
37 |
Correct |
0 ms |
256 KB |
Output is correct |
38 |
Correct |
0 ms |
256 KB |
Output is correct |
39 |
Correct |
0 ms |
256 KB |
Output is correct |
40 |
Correct |
1 ms |
256 KB |
Output is correct |
41 |
Correct |
0 ms |
256 KB |
Output is correct |
42 |
Correct |
0 ms |
256 KB |
Output is correct |
43 |
Correct |
0 ms |
256 KB |
Output is correct |
44 |
Correct |
0 ms |
256 KB |
Output is correct |
45 |
Correct |
37 ms |
384 KB |
Output is correct |
46 |
Correct |
0 ms |
384 KB |
Output is correct |
47 |
Correct |
0 ms |
256 KB |
Output is correct |
48 |
Correct |
35 ms |
384 KB |
Output is correct |
49 |
Correct |
35 ms |
384 KB |
Output is correct |
50 |
Correct |
35 ms |
384 KB |
Output is correct |
51 |
Correct |
1 ms |
256 KB |
Output is correct |
52 |
Correct |
0 ms |
256 KB |
Output is correct |
53 |
Correct |
34 ms |
384 KB |
Output is correct |
54 |
Correct |
0 ms |
256 KB |
Output is correct |
55 |
Correct |
34 ms |
384 KB |
Output is correct |
56 |
Correct |
37 ms |
384 KB |
Output is correct |
57 |
Correct |
0 ms |
256 KB |
Output is correct |
58 |
Correct |
1 ms |
384 KB |
Output is correct |
59 |
Correct |
0 ms |
384 KB |
Output is correct |
60 |
Correct |
37 ms |
384 KB |
Output is correct |
61 |
Correct |
35 ms |
384 KB |
Output is correct |
62 |
Correct |
1 ms |
256 KB |
Output is correct |
63 |
Correct |
155 ms |
384 KB |
Output is correct |
64 |
Correct |
167 ms |
504 KB |
Output is correct |
65 |
Correct |
256 ms |
452 KB |
Output is correct |
66 |
Correct |
166 ms |
384 KB |
Output is correct |
67 |
Correct |
240 ms |
596 KB |
Output is correct |
68 |
Correct |
242 ms |
384 KB |
Output is correct |
69 |
Correct |
241 ms |
384 KB |
Output is correct |
70 |
Correct |
0 ms |
256 KB |
Output is correct |
71 |
Correct |
0 ms |
256 KB |
Output is correct |
72 |
Correct |
237 ms |
584 KB |
Output is correct |
73 |
Correct |
240 ms |
504 KB |
Output is correct |
74 |
Correct |
233 ms |
384 KB |
Output is correct |
75 |
Correct |
260 ms |
384 KB |
Output is correct |
76 |
Correct |
0 ms |
256 KB |
Output is correct |
77 |
Correct |
0 ms |
256 KB |
Output is correct |
78 |
Correct |
242 ms |
468 KB |
Output is correct |
79 |
Correct |
298 ms |
504 KB |
Output is correct |
80 |
Correct |
254 ms |
504 KB |
Output is correct |
81 |
Correct |
258 ms |
384 KB |
Output is correct |
82 |
Correct |
255 ms |
384 KB |
Output is correct |
83 |
Correct |
294 ms |
508 KB |
Output is correct |
84 |
Correct |
1 ms |
384 KB |
Output is correct |
85 |
Correct |
34 ms |
384 KB |
Output is correct |
86 |
Correct |
247 ms |
384 KB |
Output is correct |
87 |
Correct |
1 ms |
256 KB |
Output is correct |
88 |
Correct |
0 ms |
256 KB |
Output is correct |
89 |
Correct |
45 ms |
384 KB |
Output is correct |
90 |
Correct |
44 ms |
384 KB |
Output is correct |
91 |
Correct |
35 ms |
384 KB |
Output is correct |
92 |
Correct |
250 ms |
384 KB |
Output is correct |
93 |
Correct |
246 ms |
504 KB |
Output is correct |
94 |
Correct |
258 ms |
384 KB |
Output is correct |
95 |
Correct |
0 ms |
256 KB |
Output is correct |
96 |
Correct |
0 ms |
256 KB |
Output is correct |
97 |
Correct |
239 ms |
504 KB |
Output is correct |
98 |
Correct |
35 ms |
384 KB |
Output is correct |
99 |
Correct |
235 ms |
384 KB |
Output is correct |
100 |
Correct |
0 ms |
256 KB |
Output is correct |
101 |
Correct |
34 ms |
384 KB |
Output is correct |
102 |
Correct |
35 ms |
384 KB |
Output is correct |
103 |
Correct |
236 ms |
472 KB |
Output is correct |
104 |
Correct |
0 ms |
256 KB |
Output is correct |
105 |
Correct |
1 ms |
256 KB |
Output is correct |
106 |
Correct |
1 ms |
256 KB |
Output is correct |
107 |
Correct |
35 ms |
412 KB |
Output is correct |
108 |
Correct |
35 ms |
384 KB |
Output is correct |
109 |
Correct |
258 ms |
468 KB |
Output is correct |
110 |
Correct |
256 ms |
504 KB |
Output is correct |
111 |
Correct |
0 ms |
256 KB |
Output is correct |