Submission #701848

# Submission time Handle Problem Language Result Execution time Memory
701848 2023-02-22T07:45:05 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{
        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++){
        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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 720 KB Output is correct
2 Correct 2 ms 848 KB Output is correct
3 Correct 2 ms 784 KB Output is correct
4 Correct 25 ms 15480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 485 ms 110640 KB Output is correct
2 Correct 469 ms 110696 KB Output is correct
3 Correct 823 ms 232860 KB Output is correct
4 Runtime error 528 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 489 ms 110772 KB Output is correct
2 Runtime error 470 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 45 ms 5584 KB Output is correct
2 Correct 110 ms 11760 KB Output is correct
3 Correct 167 ms 12664 KB Output is correct
4 Correct 905 ms 67144 KB Output is correct
5 Correct 867 ms 50736 KB Output is correct
6 Correct 166 ms 12488 KB Output is correct
7 Correct 741 ms 57532 KB Output is correct
# Verdict Execution time Memory 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 784 KB Output is correct
5 Correct 25 ms 15480 KB Output is correct
6 Correct 485 ms 110640 KB Output is correct
7 Correct 469 ms 110696 KB Output is correct
8 Correct 823 ms 232860 KB Output is correct
9 Runtime error 528 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -