Submission #660708

# Submission time Handle Problem Language Result Execution time Memory
660708 2022-11-22T20:11:42 Z Lobo The Potion of Great Power (CEOI20_potion) C++17
0 / 100
3000 ms 42760 KB
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
// #define int long long
#define ll long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

const int maxn = 2e5+10;

int n, a[maxn], idord[maxn];
vector<pair<int,int>> ord;
vector<pair<int,int>> g[maxn];

void init(int N, int D, int H[]) {
    n = N;
    for(int i = 0; i < n; i++) {
        ord.pb(mp(H[i],i));
    }
    sort(all(ord));
    for(int i = 0; i < n; i++) {
        idord[ord[i].sc] = i;
        a[i] = ord[i].fr;
    }
}

set<int> st[maxn];
void curseChanges(int U, int A[], int B[]) {
    for(int i = 0; i < U; i++) {
        int u = idord[A[i]];
        int v = idord[B[i]];

        g[u].pb(mp(i+1,v));
        g[v].pb(mp(i+1,u));
    }

    for(int i = 0; i < n; i++) {
        for(auto X : g[i]) {
            int j = X.sc;
            if(st[i].count(j)) st[i].erase(j);
            else st[i].insert(j);
        }
    }
}

int question(int x, int y, int v) {
    x = idord[x];
    y = idord[y];
    if(st[x].size() == 0) return 1000000000;
    if(st[y].size() == 0) return 1000000000;

    int ans = inf1;
    for(auto i : st[x]) {
        for(auto j : st[y]) {
            ans = min(ans, abs(a[i]-a[j]));
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 14364 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 14544 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 211 ms 42760 KB Output is correct
2 Correct 189 ms 42760 KB Output is correct
3 Correct 140 ms 21740 KB Output is correct
4 Execution timed out 3013 ms 29368 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 133 ms 42704 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 15908 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 14364 KB Incorrect
2 Halted 0 ms 0 KB -