Submission #373592

#TimeUsernameProblemLanguageResultExecution timeMemory
373592cheissmartCave (IOI13_cave)C++14
0 / 100
250 ms1004 KiB
#include "cave.h" #include <bits/stdc++.h> #define F first #define S second #define PB push_back #define MP MP make_pair #define EB emplace_back #define V vector #define ALL(v) (v).begin(), (v).end() #define debug(x) cerr << "LINE(" << __LINE__ << ") -> " << #x << " is " << (x) << endl #define ask tryCombination using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; const int INF = 1e9 + 7, N = 5005; int s[N], d[N], done[N], n; pi go(int i) { // find the switch that controls door i vi can; for(int i = 0; i < n; i++) if(!done[i]) can.PB(i); auto inv = [&] (vi& v) { for(int i:v) s[i] ^= 1; }; int x = ask(s); assert(x >= i); while(can.size() > 1) { int sz = can.size(); vi l, r; for(int i = 0; i < sz / 2; i++) l.PB(can[i]); for(int i = sz / 2; i < sz; i++) r.PB(can[i]); inv(l); int y = ask(s); inv(l); if((x == i) == (y == i)) { // in r can = r; } else { // in l can = l; } } assert(can.size() == 1); int id = can[0], state = s[id]; if(x == i) state ^= 1; return {id, state}; } void exploreCave(int _n) { n = _n; for(int i = 0; i < n; i++) { pi p = go(i); // {which switch, which state} s[p.F] = p.S; d[p.F] = i; done[p.F] = 1; } answer(s, d); }
#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...