Submission #827992

# Submission time Handle Problem Language Result Execution time Memory
827992 2023-08-17T00:54:58 Z boyliguanhan The Potion of Great Power (CEOI20_potion) C++17
0 / 100
464 ms 82796 KB
#include<bits/stdc++.h>
//#include "potion.h"
#pragma GCC optimize(2)
#define NN 100100
using namespace std;
int h[NN], n;
map<int, vector<int>> adj[NN];
void init(int N, int D, int H[]) {
    n = N;
    for(int i = 0; i < N; i++)
        h[i] = H[i];
}
set<int> arr[100100];
void curseChanges(int U, int A[], int B[]) {
    for(int i = 0; i < n; i++) adj[i][0];
    for(int i = 1; i <= U; i++) {
        int a = A[i-1], b = B[i-1];
        set<int> &x = arr[a], &y = arr[b];
        if(x.count(b)) x.erase(b), y.erase(a);
        else x.insert(b), y.insert(a);
        vector<int> x1, y1;
        for(auto j: x) x1.push_back(j);
        for(auto j: y) y1.push_back(j);
        sort(x1.begin(),x1.end());
        sort(y1.begin(), y1.end());
        adj[a][i] = x1, adj[b][i] = y1;
    }
}
int calc(vector<int> a, vector<int> b){
    int ans = 1e9;
    for(int i = 0, j = 0; i < a.size()&&j < b.size();i++) {
        if(a[i]>b[j]) swap(a, b), swap(i, j);
        if(j) ans=min(ans,abs(a[i]-b[j-1]));
        ans = min(ans, abs(a[i] - b[j]));
    }
    return ans;
}
int question(int x, int y, int v) {
    vector<int> a = (--adj[x].upper_bound(v))->second, b = (--adj[y].upper_bound(v))->second;
    vector<int> c, d;
    for(auto i: a) c.push_back(i);
    for(auto i: b) d.push_back(i);
    return calc(c,d);
}

Compilation message

potion.cpp: In function 'int calc(std::vector<int>, std::vector<int>)':
potion.cpp:31:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0, j = 0; i < a.size()&&j < b.size();i++) {
      |                           ~~^~~~~~~~~~
potion.cpp:31:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0, j = 0; i < a.size()&&j < b.size();i++) {
      |                                         ~~^~~~~~~~~~
# 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 Incorrect 5 ms 10064 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 464 ms 82740 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 449 ms 82796 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 13800 KB Incorrect
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 -