답안 #701835

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
701835 2023-02-22T07:24:38 Z Darren0724 The Potion of Great Power (CEOI20_potion) C++14
38 / 100
987 ms 262144 KB
#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;
        auto it=a1.find(b);
        if(it==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()){
        ans=min(ans,abs(h[*it]-h[*it1]));
        if(h[*it]<h[*it1]){
            it++;
        }
        else{
            it1++;
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 720 KB Output is correct
2 Correct 2 ms 848 KB Output is correct
3 Correct 3 ms 848 KB Output is correct
4 Correct 25 ms 15408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 507 ms 110780 KB Output is correct
2 Correct 495 ms 110700 KB Output is correct
3 Correct 944 ms 232828 KB Output is correct
4 Runtime error 579 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 319 ms 73104 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 5584 KB Output is correct
2 Correct 126 ms 11844 KB Output is correct
3 Correct 163 ms 12724 KB Output is correct
4 Correct 987 ms 67124 KB Output is correct
5 Correct 892 ms 50744 KB Output is correct
6 Correct 162 ms 12452 KB Output is correct
7 Correct 794 ms 57528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 2 ms 720 KB Output is correct
3 Correct 2 ms 848 KB Output is correct
4 Correct 3 ms 848 KB Output is correct
5 Correct 25 ms 15408 KB Output is correct
6 Correct 507 ms 110780 KB Output is correct
7 Correct 495 ms 110700 KB Output is correct
8 Correct 944 ms 232828 KB Output is correct
9 Runtime error 579 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -