# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
805253 |
2023-08-03T14:35:24 Z |
ma_moutahid |
Cave (IOI13_cave) |
C++17 |
|
363 ms |
680 KB |
#include <bits/stdc++.h>
#include "cave.h"
using ll =long long;
ll LINF=1000000000000000000;
int INF=1000000000;
#define pi pair<int,int>
#define pl pair<ll,ll>
#define endl '\n'
#define vi vector<int>
#define vii vector<vector<int>>
#define vl vector<ll>
#define vll vector<vector<ll>>
//#define int ll
using namespace std;
vi correct;
vi location;
int n;
void sett(int *v,int l,int r,int pos){
for(int i=0;i<l;i++){
v[i]=!pos;
}
for(int i=r+1;i<n;i++)v[i]=!pos;
for(int i=l;i<=r;i++)v[i]=pos;
}
void exploreCave(int N) {
correct.resize(N,-1);
n=N;
int combination[N];
for(int i=0;i<N;i++)combination[i]=0;
int found=0;
int cave=0;
location.resize(N,-1);
int t;
t=tryCombination(combination);
for(int i=0;i<t;i++)correct[i]=0;
correct[t]=1;
while (1){
int l=0,r=N-1;
while(l!=r){
int m=(l+r)/2;
sett(combination,m,r,correct[cave]);
t=tryCombination(combination);
if(t==-1)return;
if(t>cave)l=m;
else r=m-1;
}
location[cave]=l;
for(int i=cave;i<t;i++)correct[i]=combination[i];
correct[t]=!combination[t];
cave++;
}
}
Compilation message
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:32:9: warning: unused variable 'found' [-Wunused-variable]
32 | int found=0;
| ^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
93 ms |
664 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
363 ms |
680 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
93 ms |
664 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |