# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
303936 |
2020-09-20T19:45:51 Z |
rocks03 |
Cave (IOI13_cave) |
C++14 |
|
146 ms |
504 KB |
#include "cave.h"
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int) (x).size())
using namespace std;
void answer(int S[], int D[]);
int tryCombination(int S[]);
pii recur(int res, int l, int r, vector<int>&v, int ans[]){
if(l == r){
return {v[l], res};
}
int m = (l + r) / 2;
for(int i = l; i <= m; i++){
ans[v[i]] ^= 1;
}
int res2 = tryCombination(ans);
for(int i = l; i <= m; i++){
ans[v[i]] ^= 1;
}
if(res2 > res){
return recur(res, l, m, v, ans);
} else if(res2 == res){
return recur(res2, m+1, r, v, ans);
} else if(res2 < res){
for(int i = l; i <= m; i++){
ans[v[i]] ^= 1;
}
return recur(res2, l, m, v, ans);
}
}
void exploreCave(int N){
int ans[N], d[N];
memset(ans, 0, sizeof(ans));
memset(d, -1, sizeof(d));
vector<int> v(N);
iota(v.begin(), v.end(), 0);
while(SZ(v)){
pii p = recur(tryCombination(ans), 0, SZ(v) - 1, v, ans);
d[p.ff] = p.ss;
ans[p.ff] ^= 1;
v.erase(find(v.begin(), v.end(), p.ff));
}
answer(ans, d);
}
Compilation message
cave.cpp: In function 'std::pair<int, int> recur(int, int, int, std::vector<int>&, int*)':
cave.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
37 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
146 ms |
504 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
82 ms |
384 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
146 ms |
504 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |