Submission #112604

#TimeUsernameProblemLanguageResultExecution timeMemory
112604realityMinerals (JOI19_minerals)C++17
80 / 100
55 ms3036 KiB
#include "minerals.h" #include "bits/stdc++.h" using namespace std; #define fi first #define se second #define ll long long #define dbg(v) cerr<<#v<<" = "<<v<<'\n' #define vi vector<int> #define vl vector <ll> #define pii pair<int,int> #define vii vector < pii > #define mp make_pair #define db long double #define pb push_back #define all(s) s.begin(),s.end() template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;} template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;} template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;} template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;} const int N = 1e5 + 5; int cnt; void Go(vi a,vi b,int ok) { random_shuffle(all(b)); if (a.size() == 1) { Answer(a[0],b[0]); } else { int sz = a.size(); int m = sz / 2; if (ok) { for (int i = m;i < sz;++i) cnt = Query(a[i]); } else { for (int i = 0;i < m;++i) cnt = Query(a[i]); } vi x,y; for (auto it : b) { int cur = Query(it); if (cnt != cur) { y.pb(it); } else { x.pb(it); } cnt = cur; } Go(vi(a.begin(),a.begin() + m),x,1); Go(vi(a.begin() + m,a.end()),y,0); } } void Solve(int N) { srand(time(0)); vi a,b; for (int i = 1;i <= 2 * N;++i) { int cur = Query(i); if (cnt != cur) { a.pb(i); } else { b.pb(i); } cnt = cur; } Go(a,b,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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...