Submission #411083

#TimeUsernameProblemLanguageResultExecution timeMemory
411083amoo_safarMinerals (JOI19_minerals)C++17
80 / 100
59 ms3728 KiB
#include "minerals.h" #include <bits/stdc++.h> #define pb push_back using namespace std; const int N = 1e5; int mk[N]; int la = 0; bool Ask(int u){ mk[u] ^= 1; int res = Query(u); bool ch = la != res; la = res; return ch; } void solve(vector<int> A, vector<int> B){ assert(A.size() == B.size()); int n = A.size(); if(n == 1){ Answer(A[0], B[0]); return ; } int st = mk[A[0]]; int sz = 0; if(st == 0){ for(int i = 0; i < n / 2; i++) Ask(A[i]); sz = n / 2; } else { for(int i = 0; i < n / 2; i++) Ask(A[n - 1 - i]); sz = (n + 1) / 2; } vector<int> A2[2], B2[2]; for(int i = 0; i < sz; i++) A2[0].pb(A[i]); for(int i = sz; i < n; i++) A2[1].pb(A[i]); for(auto x : B){ bool fl = Ask(x); B2[fl ? 1 : 0].pb(x); } solve(A2[0], B2[0]); solve(A2[1], B2[1]); } void Solve(int n) { vector<int> A, B; for(int i = 1; i <= n + n; i++) if(Ask(i)) A.pb(i); else B.pb(i); solve(A, B); }
#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...