Submission #701884

# Submission time Handle Problem Language Result Execution time Memory
701884 2023-02-22T08:53:42 Z Darren0724 The Potion of Great Power (CEOI20_potion) C++17
14 / 100
446 ms 32220 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<set<int>> v;
vector<vector<int>> s;
void init(int N, int D, int H[]) {
    n=N;
    h.resize(n);
    s.resize(n);
    v.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(v[a].find(b)==v[a].end()){
            v[a].insert(b);
            v[b].insert(a);
        }
        else{
            v[a].erase(b);
            v[b].erase(a);
        }
    }
    for(int i=0;i<n;i++){
        for(int j:v[i]){
            s[i].push_back(j);
        }
        sort(s[i].begin(),s[i].end(),cmp());
    }
}

int question(int x, int y, int v) {
    int ans=1000000000;
    vector<int> a=s[x],b=s[y];
    int ptr1=0,ptr2=0;
    while(ptr1<a.size()&&ptr2<b.size()){
        int a1=a[ptr1];
        int b1=b[ptr2];
        ans=min(ans,abs(h[a1]-h[b1]));
        if(h[a1]<h[b1]){
            ptr1++;
        }
        else{
            ptr2++;
        }
    }


    return ans;
}

Compilation message

potion.cpp: In function 'int question(int, int, int)':
potion.cpp:50:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     while(ptr1<a.size()&&ptr2<b.size()){
      |           ~~~~^~~~~~~~~
potion.cpp:50:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     while(ptr1<a.size()&&ptr2<b.size()){
      |                          ~~~~^~~~~~~~~
# 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 1 ms 464 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 267 ms 32164 KB Output is correct
2 Correct 268 ms 32220 KB Output is correct
3 Correct 102 ms 9764 KB Output is correct
4 Correct 332 ms 12268 KB Output is correct
5 Correct 294 ms 23732 KB Output is correct
6 Correct 446 ms 16996 KB Output is correct
7 Correct 178 ms 17004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 220 ms 32168 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2328 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 -