제출 #1310698

#제출 시각아이디문제언어결과실행 시간메모리
1310698putuputuCave (IOI13_cave)C++20
0 / 100
169 ms600 KiB
#include "cave.h" #include<bits/stdc++.h> using namespace std; void exploreCave(int n) { auto norm = [&](int x) -> int { if (x == -1 || x == 0) return -1; return x - 1; }; vector<int> s(n, 0); vector<int> use(n, 0); vector<int> dswitch(n, -1); vector<int> state(n, 0); for(int i=0; i<n; i++){ vector<int>c; for(int j=0; j<n; j++){ if(!use[j]){ c.push_back(j); } } fill(s.begin(), s.end(), 0); for(int j=0; j<i; j++){ s[dswitch[j]]=state[j]; } int base=tryCombination(s.data()); bool doorOpen=(base==-1 or base>i); if(doorOpen){ for(int x : c){ s[x]=1; } } int l=0, r=(int)c.size()-1; int find=-1; while(l<=r){ int m=(l+r)/2; vector<int> s2=s; for(int j=l; j<=m; j++){ s2[c[j]]^=1; } int res=tryCombination(s2.data()); if(res==-1 or res>i){ find=c[m]; r=m-1; }else{ l=m+1; } } if(find==-1){ return; } vector<int> s3=s; s3[find]^=1; int res2=tryCombination(s3.data()); int need; if(res2==-1 or res2>i){ need=s3[find]; }else{ need=s[find]; } use[find]=1; dswitch[i]=find; state[i]=need; } answer(dswitch.data(), state.data()); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...