제출 #668470

#제출 시각아이디문제언어결과실행 시간메모리
668470allin27xCave (IOI13_cave)C++14
100 / 100
1358 ms968 KiB
#include <iostream> #include <vector> #include <unordered_set> #include <deque> #include "cave.h" using namespace std; int tryCombination(int S[]); void answer(int S[], int D[]); void exploreCave(int N){ int doors[N]={}; int perm[N] = {}; unordered_set<int> f; int tr[N] = {}; for (int s=0; s<N; s++){ int pos = 0; for (int i=0; i<N; i++){ if (f.count(i)) tr[i] = perm[i]; else tr[i]=0; } int r = tryCombination(tr); if (r==s) pos = 1; if (!pos) for (int i=0; i<N; i++){ if (f.count(i)) tr[i] = perm[i]; else tr[i]=1; } deque<int> av={}; for (int i=0; i<N; i++) if (!f.count(i)) av.push_back(i); int a = 0, b = (int)av.size()-1; while (a!=b){ int m = (a+b)/2; int q = a; for (auto it = av.begin(); q<=m; it++){ if (!f.count(*it)) tr[*it] = pos; q++; } r = tryCombination(tr); if (r==s) { int q = a; for (auto it = av.begin(); q<=m; it++){ if (!f.count(*it)) tr[*it] =! pos; q++; } for (int i=a; i<=m; i++) av.pop_front(); a = m+1; }else { int q = a; for (auto it = av.begin(); q<=m; it++){ if (!f.count(*it)) tr[*it] = !pos; q++; } for (int i=b; i>m; i--) av.pop_back(); b =m; } } doors[av.front()] = s; perm[av.front()] = pos; f.insert(av.front()); tr[av.front()] = pos; } answer(perm,doors); }
#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...