제출 #128858

#제출 시각아이디문제언어결과실행 시간메모리
128858Osama_AlkhodairyMinerals (JOI19_minerals)C++17
85 / 100
365 ms6284 KiB
#include <bits/stdc++.h> #include "minerals.h" //~ #include "grader.cpp" using namespace std; set <int> active; vector <int> s, e; int curl, curr; int curq; int query(int x){ if(active.count(x)) active.erase(x); else active.insert(x); return curq = Query(x); } void solve(int l, int r, vector <int> &cur){ if(r < l) return; if(l == r){ assert(cur.size() == 1); Answer(e[l], cur[0]); return; } int mid = (l + r) / 2; for(int i = l ; i <= mid ; i++){ if(active.count(e[i])) continue; query(e[i]); } for(int i = mid + 1 ; i <= r ; i++){ if(!active.count(e[i])) continue; query(e[i]); } vector <int> left, right; for(int i = 0 ; i < (int)cur.size() - 1 ; i++){ int las = curq; query(cur[i]); if(curq == las) left.push_back(cur[i]); else right.push_back(cur[i]); } if((int)left.size() != mid - l + 1) left.push_back(cur.back()); else right.push_back(cur.back()); solve(l, mid, left); solve(mid + 1, r, right); } void Solve(int N){ for(int i = 1 ; i <= 2 * N ; i++){ int prev = curq; query(i); if(curq != prev) s.push_back(i); else e.push_back(i); } curl = 0; curr = N - 1; solve(0, N - 1, s); }
#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...