# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
261669 |
2020-08-12T00:13:41 Z |
sandoval |
Cave (IOI13_cave) |
C++11 |
|
81 ms |
33036 KB |
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l, int r) {return uniform_int_distribution<>(l,r)(rng);}
constexpr int MAXN = 5002;
int a[MAXN], comb[MAXN], ass[MAXN];
int q = 0;
int printq(const vector<int>& x) {
/*cout << "?";
for (auto q : x) cout << ' ' << q;
cout << endl;
int p; cin >> p;
return p;*/
++q;
for (int i = 0; i < (int)x.size(); ++i) if (x[i] == 0) return i;
return -1;
}
int ask(const vector<int>& p) {
for (int i = 0; i < (int)p.size(); ++i) a[i] = p[i];
return tryCombination(a);
//return printq(p);
}
void solve(vector<int>& v, vector<int>& sol) {
if (v.empty()) return;
int ans = ask(sol);
if (ans == -1) return;
vector<int> ri = v;
for (auto x : v) {
sol[x] ^= 1;
int r = ask(sol);
if (r == -1) return;
sol[x] ^= 1;
if (r > ans) {
ass[x] = ans;
sol[x] ^= 1;
ri.erase(find(ri.begin(), ri.end(), x));
solve(ri, sol);
return;
} else if (r == ans) {
sol[x] ^= rnd(0,1);
} else {
ri.erase(find(ri.begin(), ri.end(), x));
ass[x] = r;
}
}
}
void exploreCave(int N) {
vector<int> p(N,0), v;
for (int i = 0; i < N; ++i) v.push_back(i), ass[i] = -1;
solve(v, p);
assert(ask(p) == -1);
for (int i = 0; i < N; ++i) comb[i] = p[i];
for (int i = 0; i < N; ++i) {
if (ass[i] == -1) {
p[i] ^= 1;
ass[i] = ask(p);
p[i] ^= 1;
}
}
answer(comb, ass);
return;
for (int i = 0; i < N; ++i) cout << comb[i] << ' ';
cout << endl;
for (int i = 0; i < N; ++i) cout << ass[i] << ' ';
cout << endl;
cout << q << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
1144 KB |
Output is correct |
2 |
Runtime error |
74 ms |
33036 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
512 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
26 ms |
512 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
24 ms |
512 KB |
Output is correct |
7 |
Correct |
28 ms |
512 KB |
Output is correct |
8 |
Correct |
29 ms |
512 KB |
Output is correct |
9 |
Correct |
28 ms |
512 KB |
Output is correct |
10 |
Correct |
30 ms |
512 KB |
Output is correct |
11 |
Correct |
26 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Incorrect |
81 ms |
760 KB |
too much calls on tryCombination() |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
1144 KB |
Output is correct |
2 |
Runtime error |
74 ms |
33036 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |