Submission #123718

# Submission time Handle Problem Language Result Execution time Memory
123718 2019-07-02T05:32:30 Z MAMBA Cave (IOI13_cave) C++17
100 / 100
1087 ms 640 KB
#include <bits/stdc++.h>
#include "cave.h"

using namespace std;

#define rep(i , j , k) for (int i = j; i < (int)k; i++)

int N, P[5010], Q[5010], local[5010];
inline bool ask(int lim , int tp, int door) {
	rep(i , 0 , lim) {
		if (~P[i])
			local[i] = Q[i];
		else
			local[i] = tp;
	}
	rep(i , lim , N) {
		if (~P[i])
			local[i] = Q[i];
		else 
			local[i] = tp ^ 1;
	}
	int res = tryCombination(local);
	return res == -1 || res > door;
}

void exploreCave(int N_) {
	N = N_;
	memset(P , -1, sizeof(P));
	memset(Q , 0 , sizeof(Q));
 	rep(i , 0 , N) {
		int tp = 0;
		if (!ask(N , tp , i))
			tp ^= 1;
		int lo = -1, hi = N - 1;
		while (lo != hi - 1) {
			int mid = lo + hi >> 1;
			if (ask(mid + 1, tp , i))
				hi = mid;
			else 
				lo = mid;
		}
		P[hi] = i;
		Q[hi] = tp;
	}	
	answer(Q , P);
}

Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:36:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    int mid = lo + hi >> 1;
              ~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 281 ms 640 KB Output is correct
2 Correct 329 ms 512 KB Output is correct
3 Correct 500 ms 640 KB Output is correct
4 Correct 316 ms 516 KB Output is correct
5 Correct 559 ms 512 KB Output is correct
6 Correct 442 ms 640 KB Output is correct
7 Correct 450 ms 640 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 6 ms 488 KB Output is correct
10 Correct 6 ms 512 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 427 ms 516 KB Output is correct
13 Correct 457 ms 420 KB Output is correct
14 Correct 421 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 426 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 455 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 511 ms 524 KB Output is correct
7 Correct 450 ms 512 KB Output is correct
8 Correct 943 ms 640 KB Output is correct
9 Correct 889 ms 512 KB Output is correct
10 Correct 963 ms 640 KB Output is correct
11 Correct 501 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 512 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 65 ms 384 KB Output is correct
21 Correct 6 ms 512 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 110 ms 460 KB Output is correct
24 Correct 114 ms 484 KB Output is correct
25 Correct 153 ms 476 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 83 ms 512 KB Output is correct
29 Correct 5 ms 512 KB Output is correct
30 Correct 62 ms 480 KB Output is correct
31 Correct 79 ms 512 KB Output is correct
32 Correct 6 ms 420 KB Output is correct
33 Correct 5 ms 484 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 106 ms 480 KB Output is correct
36 Correct 119 ms 384 KB Output is correct
37 Correct 6 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 640 KB Output is correct
2 Correct 329 ms 512 KB Output is correct
3 Correct 500 ms 640 KB Output is correct
4 Correct 316 ms 516 KB Output is correct
5 Correct 559 ms 512 KB Output is correct
6 Correct 442 ms 640 KB Output is correct
7 Correct 450 ms 640 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 6 ms 488 KB Output is correct
10 Correct 6 ms 512 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 427 ms 516 KB Output is correct
13 Correct 457 ms 420 KB Output is correct
14 Correct 421 ms 580 KB Output is correct
15 Correct 426 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 455 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 511 ms 524 KB Output is correct
21 Correct 450 ms 512 KB Output is correct
22 Correct 943 ms 640 KB Output is correct
23 Correct 889 ms 512 KB Output is correct
24 Correct 963 ms 640 KB Output is correct
25 Correct 501 ms 512 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
29 Correct 5 ms 512 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 512 KB Output is correct
32 Correct 5 ms 512 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 6 ms 384 KB Output is correct
35 Correct 6 ms 384 KB Output is correct
36 Correct 6 ms 384 KB Output is correct
37 Correct 6 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 5 ms 512 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 6 ms 512 KB Output is correct
42 Correct 6 ms 512 KB Output is correct
43 Correct 6 ms 384 KB Output is correct
44 Correct 6 ms 512 KB Output is correct
45 Correct 65 ms 384 KB Output is correct
46 Correct 6 ms 512 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 110 ms 460 KB Output is correct
49 Correct 114 ms 484 KB Output is correct
50 Correct 153 ms 476 KB Output is correct
51 Correct 6 ms 384 KB Output is correct
52 Correct 6 ms 512 KB Output is correct
53 Correct 83 ms 512 KB Output is correct
54 Correct 5 ms 512 KB Output is correct
55 Correct 62 ms 480 KB Output is correct
56 Correct 79 ms 512 KB Output is correct
57 Correct 6 ms 420 KB Output is correct
58 Correct 5 ms 484 KB Output is correct
59 Correct 5 ms 384 KB Output is correct
60 Correct 106 ms 480 KB Output is correct
61 Correct 119 ms 384 KB Output is correct
62 Correct 6 ms 452 KB Output is correct
63 Correct 311 ms 640 KB Output is correct
64 Correct 274 ms 512 KB Output is correct
65 Correct 455 ms 512 KB Output is correct
66 Correct 336 ms 588 KB Output is correct
67 Correct 490 ms 640 KB Output is correct
68 Correct 461 ms 640 KB Output is correct
69 Correct 432 ms 512 KB Output is correct
70 Correct 5 ms 384 KB Output is correct
71 Correct 5 ms 384 KB Output is correct
72 Correct 450 ms 524 KB Output is correct
73 Correct 443 ms 512 KB Output is correct
74 Correct 498 ms 640 KB Output is correct
75 Correct 561 ms 640 KB Output is correct
76 Correct 5 ms 384 KB Output is correct
77 Correct 5 ms 384 KB Output is correct
78 Correct 437 ms 512 KB Output is correct
79 Correct 501 ms 512 KB Output is correct
80 Correct 862 ms 512 KB Output is correct
81 Correct 894 ms 512 KB Output is correct
82 Correct 974 ms 588 KB Output is correct
83 Correct 566 ms 640 KB Output is correct
84 Correct 6 ms 396 KB Output is correct
85 Correct 97 ms 500 KB Output is correct
86 Correct 481 ms 640 KB Output is correct
87 Correct 6 ms 512 KB Output is correct
88 Correct 6 ms 384 KB Output is correct
89 Correct 127 ms 540 KB Output is correct
90 Correct 110 ms 476 KB Output is correct
91 Correct 119 ms 452 KB Output is correct
92 Correct 915 ms 640 KB Output is correct
93 Correct 920 ms 512 KB Output is correct
94 Correct 949 ms 512 KB Output is correct
95 Correct 6 ms 420 KB Output is correct
96 Correct 6 ms 384 KB Output is correct
97 Correct 493 ms 640 KB Output is correct
98 Correct 88 ms 476 KB Output is correct
99 Correct 437 ms 528 KB Output is correct
100 Correct 6 ms 384 KB Output is correct
101 Correct 58 ms 384 KB Output is correct
102 Correct 65 ms 384 KB Output is correct
103 Correct 411 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 125 ms 484 KB Output is correct
108 Correct 103 ms 476 KB Output is correct
109 Correct 899 ms 640 KB Output is correct
110 Correct 1087 ms 512 KB Output is correct
111 Correct 6 ms 384 KB Output is correct