Submission #641745

# Submission time Handle Problem Language Result Execution time Memory
641745 2022-09-17T14:15:18 Z Vladth11 The Potion of Great Power (CEOI20_potion) C++14
18 / 100
529 ms 62872 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 <pair <int, pair <int, int> > > events[NMAX];
set <int> st[NMAX];
int a[NMAX];
int n;
int cnt[NMAX][2];

void baga(int A, int B){
    if(st[A].find(B) == st[A].end()){
        st[A].insert(B);
        cnt[A][a[B]]++;
    }else{
        st[A].erase(B);
        cnt[A][a[B]]--;
    }
}

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

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]);
        events[A[i]].insert({i + 1, {cnt[A[i]][0], cnt[A[i]][1]}});
        events[B[i]].insert({i + 1, {cnt[B[i]][0], cnt[B[i]][1]}});
    }
}

int question(int x, int y, int v) {
    pii ultimX = (*prev(events[x].upper_bound({v + 1, {-1, -1}}))).second;
    pii ultimY = (*prev(events[y].upper_bound({v + 1, {-1, -1}}))).second;
    if(ultimX.first + ultimX.second == 0 || ultimY.first + ultimY.second == 0)
        return 1e9;
    if(ultimX.first > 0 && ultimY.first > 0)
        return 0;
    if(ultimX.second > 0 && ultimY.second > 0)
        return 0;
    return 1;
}

# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 9680 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 19692 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 66 ms 36960 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 473 ms 62872 KB Output is correct
2 Correct 341 ms 44556 KB Output is correct
3 Correct 464 ms 49424 KB Output is correct
4 Correct 525 ms 49404 KB Output is correct
5 Correct 501 ms 62508 KB Output is correct
6 Correct 529 ms 49396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 21072 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 9680 KB Incorrect
2 Halted 0 ms 0 KB -