# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
851454 |
2023-09-19T19:51:56 Z |
hariaakas646 |
Cave (IOI13_cave) |
C++17 |
|
241 ms |
600 KB |
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
void usaco()
{
freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
// freopen("problem.out", "w", stdout);
}
void exploreCave(int n) {
int out[n];
frange(i, n) out[i] = -1;
int pos[n];
forr(j, 1, n+1) {
int vec[n];
frange(i, n)
vec[i] = out[i];
int k = 0;
frange(i, n) {
if(out[i] == -1) {vec[i] = 0;k++;}
else vec[i] = out[i];
}
int v = tryCombination(vec);
int c;
if(v == -1 || v >= j) c = 0;
else c = 1;
int st = 0;
int en = n;
while(k > 1) {
int x = 0;
int m;
forr(i, st, en) {
if(out[i] == -1) {
vec[i] = c;
x++;
}
else vec[i] = out[i];
if(x >= k/2) {
m = i;
break;
}
}
forr(i, m+1, en) {
if(out[i] == -1) {
vec[i] = !c;
}
}
int v = tryCombination(vec);
if(v == -1 || v >= j) {
k = x;
en = m+1;
}
else {
k = k - x;
st = m+1;
}
}
forr(i, st, en) {
if(out[i] == -1) {
out[i] = c;
pos[i] = j-1;
break;
}
}
}
answer(out, pos);
}
// int main() {
// usaco();
// int N;
// N = init();
// exploreCave(N);
// printf("INCORRECT\nYour solution did not call answer().\n");
// return 0;
// }
Compilation message
cave.cpp: In function 'void usaco()':
cave.cpp:38:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
38 | freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:76:18: warning: 'm' may be used uninitialized in this function [-Wmaybe-uninitialized]
76 | forr(i, m+1, en) {
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
125 ms |
348 KB |
Output is correct |
2 |
Correct |
130 ms |
536 KB |
Output is correct |
3 |
Correct |
203 ms |
556 KB |
Output is correct |
4 |
Correct |
127 ms |
344 KB |
Output is correct |
5 |
Correct |
202 ms |
556 KB |
Output is correct |
6 |
Correct |
183 ms |
556 KB |
Output is correct |
7 |
Correct |
205 ms |
556 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
184 ms |
560 KB |
Output is correct |
13 |
Correct |
187 ms |
556 KB |
Output is correct |
14 |
Correct |
186 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
213 ms |
524 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
177 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
210 ms |
556 KB |
Output is correct |
7 |
Correct |
210 ms |
552 KB |
Output is correct |
8 |
Correct |
235 ms |
556 KB |
Output is correct |
9 |
Correct |
233 ms |
552 KB |
Output is correct |
10 |
Correct |
233 ms |
348 KB |
Output is correct |
11 |
Correct |
204 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
30 ms |
492 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
31 ms |
348 KB |
Output is correct |
24 |
Correct |
31 ms |
344 KB |
Output is correct |
25 |
Correct |
32 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
29 ms |
500 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
27 ms |
348 KB |
Output is correct |
31 |
Correct |
30 ms |
480 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
30 ms |
476 KB |
Output is correct |
36 |
Correct |
30 ms |
348 KB |
Output is correct |
37 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
125 ms |
348 KB |
Output is correct |
2 |
Correct |
130 ms |
536 KB |
Output is correct |
3 |
Correct |
203 ms |
556 KB |
Output is correct |
4 |
Correct |
127 ms |
344 KB |
Output is correct |
5 |
Correct |
202 ms |
556 KB |
Output is correct |
6 |
Correct |
183 ms |
556 KB |
Output is correct |
7 |
Correct |
205 ms |
556 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
184 ms |
560 KB |
Output is correct |
13 |
Correct |
187 ms |
556 KB |
Output is correct |
14 |
Correct |
186 ms |
348 KB |
Output is correct |
15 |
Correct |
213 ms |
524 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
177 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
210 ms |
556 KB |
Output is correct |
21 |
Correct |
210 ms |
552 KB |
Output is correct |
22 |
Correct |
235 ms |
556 KB |
Output is correct |
23 |
Correct |
233 ms |
552 KB |
Output is correct |
24 |
Correct |
233 ms |
348 KB |
Output is correct |
25 |
Correct |
204 ms |
592 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
30 ms |
492 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
31 ms |
348 KB |
Output is correct |
49 |
Correct |
31 ms |
344 KB |
Output is correct |
50 |
Correct |
32 ms |
348 KB |
Output is correct |
51 |
Correct |
1 ms |
348 KB |
Output is correct |
52 |
Correct |
0 ms |
348 KB |
Output is correct |
53 |
Correct |
29 ms |
500 KB |
Output is correct |
54 |
Correct |
0 ms |
348 KB |
Output is correct |
55 |
Correct |
27 ms |
348 KB |
Output is correct |
56 |
Correct |
30 ms |
480 KB |
Output is correct |
57 |
Correct |
0 ms |
348 KB |
Output is correct |
58 |
Correct |
0 ms |
348 KB |
Output is correct |
59 |
Correct |
0 ms |
348 KB |
Output is correct |
60 |
Correct |
30 ms |
476 KB |
Output is correct |
61 |
Correct |
30 ms |
348 KB |
Output is correct |
62 |
Correct |
1 ms |
344 KB |
Output is correct |
63 |
Correct |
122 ms |
348 KB |
Output is correct |
64 |
Correct |
134 ms |
348 KB |
Output is correct |
65 |
Correct |
193 ms |
344 KB |
Output is correct |
66 |
Correct |
138 ms |
540 KB |
Output is correct |
67 |
Correct |
199 ms |
348 KB |
Output is correct |
68 |
Correct |
183 ms |
348 KB |
Output is correct |
69 |
Correct |
199 ms |
560 KB |
Output is correct |
70 |
Correct |
1 ms |
348 KB |
Output is correct |
71 |
Correct |
0 ms |
348 KB |
Output is correct |
72 |
Correct |
202 ms |
560 KB |
Output is correct |
73 |
Correct |
212 ms |
348 KB |
Output is correct |
74 |
Correct |
183 ms |
556 KB |
Output is correct |
75 |
Correct |
170 ms |
556 KB |
Output is correct |
76 |
Correct |
0 ms |
348 KB |
Output is correct |
77 |
Correct |
0 ms |
348 KB |
Output is correct |
78 |
Correct |
239 ms |
556 KB |
Output is correct |
79 |
Correct |
210 ms |
556 KB |
Output is correct |
80 |
Correct |
241 ms |
572 KB |
Output is correct |
81 |
Correct |
234 ms |
556 KB |
Output is correct |
82 |
Correct |
235 ms |
348 KB |
Output is correct |
83 |
Correct |
199 ms |
556 KB |
Output is correct |
84 |
Correct |
0 ms |
344 KB |
Output is correct |
85 |
Correct |
28 ms |
348 KB |
Output is correct |
86 |
Correct |
194 ms |
560 KB |
Output is correct |
87 |
Correct |
1 ms |
344 KB |
Output is correct |
88 |
Correct |
1 ms |
348 KB |
Output is correct |
89 |
Correct |
30 ms |
500 KB |
Output is correct |
90 |
Correct |
30 ms |
348 KB |
Output is correct |
91 |
Correct |
31 ms |
344 KB |
Output is correct |
92 |
Correct |
231 ms |
600 KB |
Output is correct |
93 |
Correct |
225 ms |
344 KB |
Output is correct |
94 |
Correct |
227 ms |
556 KB |
Output is correct |
95 |
Correct |
0 ms |
348 KB |
Output is correct |
96 |
Correct |
0 ms |
348 KB |
Output is correct |
97 |
Correct |
144 ms |
556 KB |
Output is correct |
98 |
Correct |
37 ms |
348 KB |
Output is correct |
99 |
Correct |
193 ms |
556 KB |
Output is correct |
100 |
Correct |
1 ms |
348 KB |
Output is correct |
101 |
Correct |
29 ms |
496 KB |
Output is correct |
102 |
Correct |
29 ms |
344 KB |
Output is correct |
103 |
Correct |
207 ms |
348 KB |
Output is correct |
104 |
Correct |
0 ms |
344 KB |
Output is correct |
105 |
Correct |
0 ms |
348 KB |
Output is correct |
106 |
Correct |
0 ms |
344 KB |
Output is correct |
107 |
Correct |
30 ms |
348 KB |
Output is correct |
108 |
Correct |
30 ms |
348 KB |
Output is correct |
109 |
Correct |
236 ms |
556 KB |
Output is correct |
110 |
Correct |
227 ms |
348 KB |
Output is correct |
111 |
Correct |
0 ms |
348 KB |
Output is correct |