Submission #303936

#TimeUsernameProblemLanguageResultExecution timeMemory
303936rocks03Cave (IOI13_cave)C++14
0 / 100
146 ms504 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[]); pii recur(int res, int l, int r, vector<int>&v, int ans[]){ if(l == r){ return {v[l], res}; } 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(res2 > res){ return recur(res, l, m, v, ans); } else if(res2 == res){ return recur(res2, m+1, r, v, ans); } else if(res2 < res){ for(int i = l; i <= m; i++){ ans[v[i]] ^= 1; } return recur(res2, l, m, v, ans); } } void exploreCave(int N){ int ans[N], d[N]; memset(ans, 0, sizeof(ans)); memset(d, -1, sizeof(d)); vector<int> v(N); iota(v.begin(), v.end(), 0); while(SZ(v)){ pii p = recur(tryCombination(ans), 0, SZ(v) - 1, v, ans); d[p.ff] = p.ss; ans[p.ff] ^= 1; v.erase(find(v.begin(), v.end(), p.ff)); } answer(ans, d); }

Compilation message (stderr)

cave.cpp: In function 'std::pair<int, int> recur(int, int, int, std::vector<int>&, int*)':
cave.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^
#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...