Submission #578943

#TimeUsernameProblemLanguageResultExecution timeMemory
578943BelguteiCave (IOI13_cave)C++17
100 / 100
181 ms568 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair int l,r; vector<int> v; vector<int> :: iterator it; void exploreCave(int N) { int x[N]; int a[N]; int tp[N]; int ans[N]; memset(a, 0, sizeof(a)); // for(int i = 0; i < N; i ++) { v.pb(i); } // memset(tp, -1, sizeof(tp)); // int pre = tryCombination(a); if(pre == -1) pre = N; for(int i = 0; i < N; i ++) { l = 0; r = v.size() - 1; while(l < r) { int mid = (l + r) / 2; for(int j = l; j <= mid; j ++) { a[v[j]] = 1 - a[v[j]]; } int tmp = tryCombination(a); if(tmp == -1) tmp = N; if(pre <= i && tmp > i) { r = mid; } else if(pre <= i && tmp <= i) { l = mid + 1; } else if(pre > i && tmp <= i) { r = mid; } else l = mid + 1; pre = tmp; //cout << l << ' ' << r << '\n'; } ans[v[l]] = i; if(pre > i) { tp[v[l]] = a[v[l]]; } else { a[v[l]] = 1 - a[v[l]]; tp[v[l]] = a[v[l]]; pre = tryCombination(a); if(pre == -1) pre = N; } it = lower_bound(v.begin(), v.end(), v[l]); v.erase(it); } answer(tp, ans); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:17:9: warning: unused variable 'x' [-Wunused-variable]
   17 |     int x[N];
      |         ^
#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...