이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |