Submission #641737

# Submission time Handle Problem Language Result Execution time Memory
641737 2022-09-17T14:00:21 Z Vladth11 The Potion of Great Power (CEOI20_potion) C++14
0 / 100
3000 ms 26248 KB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;

const int NMAX = 100001;
const int VMAX = 101;
const int INF = 2e9;
const int MOD = 1000000007;
const int BLOCK = 447;
const int base = 117;
const int nr_of_bits = 24;
const int inv2 = 500000004;

set <int> events[NMAX];
int a[NMAX];

void init(int N, int D, int H[]) {
    for(int i = 0; i < N; i++){
        a[i] = H[i];
    }
}

void baga(int a, int b){
    if(events[a].find(b) == events[a].end())
        events[a].insert(b);
    else
        events[a].erase(b);
}

void curseChanges(int U, int A[], int B[]) {
    for(int i = 0; i < U; i++){
        baga(A[i], B[i]);
        baga(B[i], A[i]);
    }
}

int question(int x, int y, int v) {
    int minim = 1e9;
    if(events[x].size() == 0 || events[y].size() == 0)
        return minim;
    set <int> nou;
    for(auto p : events[x]){
        nou.insert(a[p]);
    }
    for(auto p : events[y]){
        int val = a[p];
        auto it = nou.lower_bound(val);
        if(it != nou.end()){
            minim = min(minim, abs((*it) - val));
        }
        it = nou.upper_bound(val);
        if(it != nou.begin()){
            it = prev(it);
            minim = min(minim, abs((*it) - val));
        }
    }
    return minim;
}

# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4944 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5072 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 277 ms 26028 KB Output is correct
2 Correct 257 ms 26108 KB Output is correct
3 Correct 169 ms 7408 KB Output is correct
4 Execution timed out 3028 ms 15840 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 26248 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 6076 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4944 KB Incorrect
2 Halted 0 ms 0 KB -