Submission #1043074

# Submission time Handle Problem Language Result Execution time Memory
1043074 2024-08-03T21:32:25 Z beaconmc The Potion of Great Power (CEOI20_potion) C++14
18 / 100
2940 ms 37836 KB
#include <bits/stdc++.h>
 
typedef int ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
 
using namespace std;
 
 

vector<ll> h;
vector<ll> a;
vector<ll> b;
vector<ll> sus[100001][2];
 
void init(int N, int D, int H[]) {
    FOR(i,0,N) h.push_back(H[i]);
}
 
void curseChanges(int U, int A[], int B[]) {
    vector<set<ll>> tempedges;
    tempedges.resize(100001);
    FOR(i,0,U){
        
        a.push_back(A[i]);
        b.push_back(B[i]);
        bool onea=0, oneb=0, zeroa=0, zerob=0;
        bool onea2=0, oneb2=0, zeroa2=0, zerob2=0;
        for (auto&i : tempedges[A[i]]){
            if (h[i] == 0) zeroa = 1;
            if (h[i]==1) onea=1;
        }
        for (auto&i : tempedges[B[i]]){
            if (h[i] == 0) zerob = 1;
            if (h[i]==1) oneb=1;
        }
        if (tempedges[A[i]].find(B[i]) != tempedges[A[i]].end()) tempedges[A[i]].erase(B[i]);
        else tempedges[A[i]].insert(B[i]);
 
        if (tempedges[B[i]].find(A[i]) != tempedges[B[i]].end()) tempedges[B[i]].erase(A[i]);
        else tempedges[B[i]].insert(A[i]);

        for (auto&i : tempedges[A[i]]){
            if (h[i] == 0) zeroa2 = 1;
            if (h[i]==1) onea2=1;
        }
        for (auto&i : tempedges[B[i]]){
            if (h[i] == 0) zerob2 = 1;
            if (h[i]==1) oneb2=1;
        }
        if (onea != onea2) sus[A[i]][1].push_back(i);
        if (oneb != oneb2) sus[B[i]][1].push_back(i);
        if (zeroa != zeroa2) sus[A[i]][0].push_back(i);
        if (zerob != zerob2) sus[B[i]][0].push_back(i);
    }
}
 
int mindiff(set<ll>&a, set<ll>&b){

    ll ans = 1000000000;
    vector<pair<ll,ll>> A,B;

    for (auto&i : a) A.push_back(make_pair(h[i], (ll)0));
    for (auto&i : b) A.push_back(make_pair(h[i], (ll) 1));
 
    sort(A.begin(), A.end());
    if (A.size()==0) return ans;
    FOR(i,0,A.size()-1){
        if (A[i].second != A[i+1].second) ans = min(ans, abs(A[i].first-A[i+1].first));
    }

    return ans;
}
 
int question(int x, int y, int v) {
    v--;
    ll ans = 1000000000;
    bool onex=0, zerox=0, zeroy=0,oney=0;
    onex = (upper_bound(sus[x][1].begin(), sus[x][1].end(),v)-sus[x][1].begin())%2;
    zerox = (upper_bound(sus[x][0].begin(), sus[x][0].end(),v)-sus[x][0].begin())%2;
    oney = (upper_bound(sus[y][1].begin(), sus[y][1].end(),v)-sus[y][1].begin())%2;
    zeroy = (upper_bound(sus[y][0].begin(), sus[y][0].end(),v)-sus[y][0].begin())%2;
    vector<ll> X,Y;
    if (onex) X.push_back(1);
    if (zerox) X.push_back(0);
    if (oney) Y.push_back(1);
    if (zeroy) Y.push_back(0);
    for (auto&i : X) for (auto&j : Y) ans = min(ans, abs(i-j));

 
    return ans;
}

Compilation message

potion.cpp: In function 'int mindiff(std::set<int>&, std::set<int>&)':
potion.cpp:4:33: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define FOR(i,x,y) for(ll i=x; i<y; i++)
......
   68 |     FOR(i,0,A.size()-1){
      |         ~~~~~~~~~~~~~~           
potion.cpp:68:5: note: in expansion of macro 'FOR'
   68 |     FOR(i,0,A.size()-1){
      |     ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 9816 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 9812 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 32496 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 158 ms 37836 KB Output is correct
2 Correct 1326 ms 15688 KB Output is correct
3 Correct 1518 ms 21928 KB Output is correct
4 Correct 2879 ms 22048 KB Output is correct
5 Correct 340 ms 37284 KB Output is correct
6 Correct 2940 ms 21928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 10840 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 9816 KB Incorrect
2 Halted 0 ms 0 KB -