Submission #669614

# Submission time Handle Problem Language Result Execution time Memory
669614 2022-12-06T20:47:56 Z dozer The Potion of Great Power (CEOI20_potion) C++14
14 / 100
1972 ms 36020 KB
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define sp " "
//#define endl "\n"
#define pii pair<int, int>
#define st first
#define nd second


vector<pair<pii, int>> curr[100005];
int arr[100005], n;


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

void curseChanges(int U, int A[], int B[]) {
    map<int, int> last[n + 5];
    for (int i = 0; i < U; i++)
    {
        int u = A[i], v = B[i];
        if (last[u][v])
        {
            curr[u].pb({{last[u][v], i + 1}, v});
            curr[v].pb({{last[u][v], i + 1}, u});
            last[u][v] = 0;
            last[v][u] = 0;
        }
        else last[u][v] = i + 1, last[v][u] = i + 1;
    }
    for (int i = 0; i < n; i++)
    {
        for (auto j : last[i])
        {
            if (j.nd != 0) curr[i].pb({{j.nd, U + 2}, arr[j.st]});
        }
    }
}

int question(int x, int y, int v) {
    vector<int> k, l;
    v++;
    for (auto i : curr[x])
        if (i.st.st <= v && i.st.nd >= v) k.pb(i.nd);
    for (auto i : curr[y])
        if (i.st.st <= v && i.st.nd >= v) l.pb(i.nd);
    sort(k.begin(), k.end());
    sort(l.begin(), l.end());
    int ans = 1e9;
    int i = 0, j = 0;
    /*
    cout<<x<<" : ";
    for (auto i : k) cout<<i<<sp;
    cout<<endl;
    cout<<y<<" : ";
    for (auto i : l) cout<<i<<sp;
        cout<<endl;*/
    while(i < k.size() && j < l.size())
    {
        int a = k[i], b = l[j];
        ans = min(ans, abs(a - b));
        if (a < b) i++;
        else if (b < a) j++;
        else return ans;
    }
    return ans;

}

Compilation message

potion.cpp: In function 'int question(int, int, int)':
potion.cpp:64:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     while(i < k.size() && j < l.size())
      |           ~~^~~~~~~~~~
potion.cpp:64:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     while(i < k.size() && j < l.size())
      |                           ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2640 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2768 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 265 ms 36020 KB Output is correct
2 Correct 274 ms 35804 KB Output is correct
3 Correct 322 ms 12612 KB Output is correct
4 Correct 1105 ms 24548 KB Output is correct
5 Correct 461 ms 30800 KB Output is correct
6 Correct 1972 ms 23356 KB Output is correct
7 Correct 376 ms 23248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 237 ms 35912 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 4596 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2640 KB Incorrect
2 Halted 0 ms 0 KB -