Submission #303918

#TimeUsernameProblemLanguageResultExecution timeMemory
303918rocks03Cave (IOI13_cave)C++14
13 / 100
109 ms640 KiB
#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[]); int recur(int res, int l, int r, vector<int>&v, int ans[]){ if(l == r){ return v[l]; } 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(res != res2){ return recur(res, l, m, v, ans); } else{ return recur(res, m+1, r, v, ans); } } void exploreCave(int N){ int ans[N], d[N]; memset(ans, 0, sizeof(ans)); memset(d, -1, sizeof(d)); while(true){ vector<int> v; for(int i = 0; i < N; i++){ if(d[i] == -1){ v.pb(i); } } if(!SZ(v)) break; int res = tryCombination(ans); if(res == -1) break; int get = recur(res, 0, SZ(v) - 1, v, ans); d[get] = res; ans[get] ^= 1; } for(int i = 0; i < N; i++){ if(d[i] == -1){ ans[i] ^= 1; d[i] = tryCombination(ans); ans[i] ^= 1; } } answer(ans, 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...