Submission #866109

# Submission time Handle Problem Language Result Execution time Memory
866109 2023-10-25T12:31:34 Z danikoynov The Potion of Great Power (CEOI20_potion) C++14
17 / 100
3000 ms 6512 KB
#include<bits/stdc++.h>

using namespace std;
    


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

const int maxq = 50010;

pair < int, int > edge[maxq];

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

int question(int x, int y, int v) 
{
    set < int > sx, sy;

    for (int i = 0; i < v; i ++)
    {
        int a = edge[i].first;
        int b = edge[i].second;

        if (a == x)
        {
            if (sx.find(b) == sx.end())
                sx.insert(b);
            else
                sx.erase(b);
        }
        
        if (b == x)
        {
            if (sx.find(a) == sx.end())
                sx.insert(a);
            else
                sx.erase(a);
        }

        if (a == y)
        {
            if (sy.find(b) == sy.end())
                sy.insert(b);
            else
                sy.erase(b);
        }
        
        if (b == y)
        {
            if (sy.find(a) == sy.end())
                sy.insert(a);
            else
                sy.erase(a);
        }
    }

    if (sx.empty() && sy.empty())
        return 1e9;
    /**cout << "--------------" << endl;
    for (int a : sx)
        cout << a << " ";
    cout << endl;
    for (int b : sy)
        cout << b << " ";
        cout << endl;*/
    int ans = 1e9;
    for (int a : sx)
        for (int b : sy)
            ans = min(ans, abs(h[a] - h[b]));
    
    return ans;
    
}
/**
6 5 11 4
2 42 1000 54 68 234
0 1
2 0
3 4
3 5
3 5
1 3
5 3
0 5
3 0
1 3
3 5
0 3 4
3 0 8
0 5 5
3 0 11
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 11 ms 1852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 6512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 6240 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 366 ms 600 KB Output is correct
2 Correct 593 ms 856 KB Output is correct
3 Correct 2959 ms 856 KB Output is correct
4 Execution timed out 3032 ms 856 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 11 ms 1852 KB Output is correct
6 Runtime error 39 ms 6512 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -