Submission #701847

# Submission time Handle Problem Language Result Execution time Memory
701847 2023-02-22T07:44:36 Z Darren0724 The Potion of Great Power (CEOI20_potion) C++17
0 / 100
467 ms 134144 KB
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> h;
struct cmp{
    bool operator()(const int &a,const int &b)const{
        if(h[a]==h[b]){
            return a<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++){
        a1.insert(i);
        s[i][0]=a1;
        a1.erase(i);
    }
}

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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 976 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 467 ms 133996 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 463 ms 134144 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 6992 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -