답안 #701841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
701841 2023-02-22T07:27:01 Z Darren0724 The Potion of Great Power (CEOI20_potion) C++17
38 / 100
905 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)const{
        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;
        bool flag=a1.find(b)==a1.end();
        if(flag){
            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 2 ms 848 KB Output is correct
4 Correct 23 ms 15472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 470 ms 110636 KB Output is correct
2 Correct 489 ms 110704 KB Output is correct
3 Correct 825 ms 232880 KB Output is correct
4 Runtime error 526 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 288 ms 73208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 5584 KB Output is correct
2 Correct 115 ms 11852 KB Output is correct
3 Correct 167 ms 12724 KB Output is correct
4 Correct 905 ms 67128 KB Output is correct
5 Correct 851 ms 50692 KB Output is correct
6 Correct 145 ms 12488 KB Output is correct
7 Correct 785 ms 57556 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 2 ms 848 KB Output is correct
5 Correct 23 ms 15472 KB Output is correct
6 Correct 470 ms 110636 KB Output is correct
7 Correct 489 ms 110704 KB Output is correct
8 Correct 825 ms 232880 KB Output is correct
9 Runtime error 526 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -