Submission #578095

# Submission time Handle Problem Language Result Execution time Memory
578095 2022-06-16T04:36:49 Z tengiz05 The Potion of Great Power (CEOI20_potion) C++17
0 / 100
3000 ms 11276 KB
#include <bits/stdc++.h>
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;

constexpr int N = 1E5, B = 2, D = 2;
int h[N], n;
vector<pair<int, int>> mv[N];

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

void curseChanges(int U, int A[], int B[]) {
    for (int i = 0; i < U; i++) {
        mv[A[i]].emplace_back(i, B[i]);
        mv[B[i]].emplace_back(i, A[i]);
    }
    // for (int i = 0; i < n; i++) {
        // if (move[i].size() >= B) {
            
        // }
    // }
}

int question(int x, int y, int v) {
    multiset<int> a, ha;
    multiset<int> b, hb;
    for (int i = 0; i < int(mv[x].size()) && mv[x][i].first <= v; i++) {
        int g = mv[x][i].second;
        if (a.count(g)) {
            a.erase(g);
            ha.erase(ha.find(h[g]));
        } else {
            a.insert(g);
            ha.insert(h[g]);
        }
    }
    for (int i = 0; i < int(mv[y].size()) && mv[y][i].first <= v; i++) {
        int g = mv[y][i].second;
        if (b.count(g)) {
            b.erase(g);
            hb.erase(hb.find(h[g]));
        } else {
            b.insert(g);
            hb.insert(h[g]);
        }
    }
    vector<int> B(hb.begin(), hb.end());
    int i = 0;
    int ans = 1E9;
    for (auto x : ha) {
        while (i < int(B.size()) && B[i] < x)
            i++;
        if (i > 0) {
            ans = min(ans, x - B[i - 1]);
        }
        if (i < int(B.size())) {
            ans = min(ans, B[i] - x);
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2640 KB Output is correct
2 Incorrect 3 ms 2640 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 189 ms 11268 KB Output is correct
2 Correct 200 ms 11252 KB Output is correct
3 Execution timed out 3068 ms 8752 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 150 ms 11276 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 3152 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 4 ms 2640 KB Output is correct
3 Incorrect 3 ms 2640 KB Incorrect
4 Halted 0 ms 0 KB -