# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
701833 | Darren0724 | The Potion of Great Power (CEOI20_potion) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> h;
struct cmp{
bool operator()(const int &a,const int &b){
return h[a]<h[b];
}
};
vector<map<int,set<int,cmp>>> s;
void init(int N, int D, int H[]) {
n=N;
h.resize(n);
s.resize(n);
for(int i=0;i<n;i++){
h[i]=H[i];
}
set<int,cmp> a1;
for(int i=0;i<n;i++){
s[i][0]=a1;
}
}
void curseChanges(int U, int A[], int B[]) {
for(int i=1;i<=U;i++){
int a=A[i-1];
int b=B[i-1];
set<int,cmp> a1=(--s[a].end())->second;
set<int,cmp> b1=(--s[b].end())->second;
if(a1.find(b)==a1.end()){
a1.insert(b);
b1.insert(a);
}
else{
a1.erase(b);
b1.erase(a);
}
s[a][i]=a1;
s[b][i]=b1;
}
for(int i=0;i<n;i++){
for(auto j:s[i]){
cout<<i<<' '<<j.first<<':';
for(int k:j.second){
cout<<k<<' ';
}
cout<<endl;
}
}
}
int question(int x, int y, int v) {
set<int,cmp> s1;
set<int,cmp> a=(--s[x].upper_bound(v))->second;
set<int,cmp> b=(--s[y].upper_bound(v))->second;
auto it=a.begin();
auto it1=b.begin();
int ans=1000000000;
while(it!=a.end()&&it1!=b.end()){
cout<<*it<<' '<<*it1<<endl;
ans=min(ans,abs(h[*it]-h[*it1]));
if(h[*it]<h[*it1]){
it++;
}
else{
it1++;
}
}
return ans;
}