# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
342409 | urd05 | The Potion of Great Power (CEOI20_potion) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n,d;
int h[100000];
int a[100000];
int b[100000];
int u;
bool iscon0[100000];
bool iscon1[100000];
typedef pair<int,int> P;
P ind[100000];
void init(int N, int D, int H[]) {
n=N;
d=D;
for(int i=0;i<n;i++) {
ind[i]=P(H[i],i);
h[i]=H[i];
}
sort(ind,ind+n);
}
void curseChanges(int U, int A[], int B[]) {
u=U;
for(int i=0;i<u;i++) {
a[i]=A[i];
b[i]=B[i];
}
}
int question(int x, int y, int v) {
memset(iscon0,0,sizeof(iscon0));
memste(iscon1,0,sizeof(iscon1));
iscon0[x]=true;
iscon1[y]=true;
for(int i=0;i<v;i++) {
if (a[i]==x) {
iscon0[b[i]]^=1;
}
else if (b[i]==x) {
iscon0[a[i]]^=1;
}
if (a[i]==y) {
iscon1[b[i]]^=1;
}
else if (b[i]==y) {
iscon1[a[i]]^=1;
}
}
int ret=1e9;
vector<P> one;
vector<P> two;
for(int i=0;i<n;i++) {
if (iscon0[ind[i].second]) {
one.push_back(P(ind[i].first,0));
}
}
for(int i=0;i<n;i++) {
if (iscon1[ind[i].second]) {
two.push_back(P(ind[i].first,1));
}
}
vector<P> vec;
merge(one.begin(),one.end(),two.begin(),two.end(),vec.begin());
for(int i=0;i+1<vec.size();i++) {
if (vec[i].second!=vec[i+1].second) {
ret=min(ret,vec[i+1].first-vec[i].first);
}
}
return ret;
}