Submission #701879

# Submission time Handle Problem Language Result Execution time Memory
701879 2023-02-22T08:34:35 Z Darren0724 The Potion of Great Power (CEOI20_potion) C++17
0 / 100
3000 ms 101600 KB
#pragma GCC optimize("Ofast","O3")
#pragma GCC target("avx2")
#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<unordered_map<int,vector<pair<int,int>>>> 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];
    }
}

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];
        if(s[a].find(b)==s[a].end()||s[a][b].back().second==0){
            s[a][b].push_back({i,1});
            s[b][a].push_back({i,1});
        }
        else{
            s[a][b].push_back({i,0});
            s[b][a].push_back({i,0});
        }
    }
}

int question(int x, int y, int v) {
    int ans=1000000000;
    vector<int> a(2),b(2);

    for(pair<int,vector<pair<int,int>>> j:s[x]){
        int tmp=(--upper_bound(j.second.begin(),j.second.end(),make_pair(v,10)))->second;
        if(tmp==1){
            a[h[j.first]]=1;
        }
    }
    for(pair<int,vector<pair<int,int>>> j:s[y]){
        int tmp=(--upper_bound(j.second.begin(),j.second.end(),make_pair(v,10)))->second;
        if(tmp==1){
            b[h[j.first]]=1;
        }
    }
    if(a[0]==1&&b[0]==1){
        return 0;
    }
    if(a[1]==1&&b[1]==1){
        return 0;
    }
    if(a[0]==1&&b[1]==1){
        return 1;
    }
    if(a[1]==1&&b[0]==1){
        return 1;
    }


    return ans;
}

# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1104 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 240 ms 101600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 338 ms 50224 KB Output is correct
2 Execution timed out 3034 ms 23112 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 6948 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -