Submission #571967

#TimeUsernameProblemLanguageResultExecution timeMemory
571967SlavicGCave (IOI13_cave)C++17
0 / 100
287 ms392 KiB
#include "cave.h" #include "bits/stdc++.h" using namespace std; #define ll long long #define forn(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(),v.rend() #define pb push_back #define sz(a) (int)a.size() /* int tryCombination(vector<int> s) { for(auto x: s) cout << x << " "; cout << "\n"; int f; cin >> f; return f; } void answer(vector<int> s, vector<int> d) { for(auto x: s) cout << x << " "; cout << "\n"; for(auto x: d) cout << x << " "; cout << "\n"; } */ void exploreCave(int n) { int d[n], s[n]; forn(i, n) d[i] = s[i] = -1; for(int i = 0; i < n; ++i) { int tmp[n]; forn(j, n) tmp[j] = s[j]; forn(j, n) if(s[j] == -1) tmp[j] = 0; int x = tryCombination(tmp); int need = 0; if(x == -1) x = n; if(x <= i) { need = 1; forn(j, n) if(s[j] == -1) tmp[j] = 1; } d[i] = need; int l = 0, r = n - 1, pos = -1; while(l <= r) { int rem[n]; forn(j, n) rem[j] = tmp[j]; int mid = l + r >> 1; for(int j = mid; j < n; ++j) { if(s[j] == -1) { tmp[j] = !need; } } x = tryCombination(tmp); if(x == -1) x = n; if(x <= i) { r = mid - 1; } else { pos = mid; l = mid + 1; } forn(j, n) tmp[j] = rem[j]; } s[pos] = i; } answer(d, s); } /* void solve() { int n; cin >> n; exploreCave(n); } int32_t main() { //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t = 1; //cin >> t; while(t--) { solve(); } } */

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:50:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   50 |             int mid = l + r >> 1;
      |                       ~~^~~
#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...