Submission #1159389

#TimeUsernameProblemLanguageResultExecution timeMemory
1159389timoniThe Potion of Great Power (CEOI20_potion)C++20
Compilation error
0 ms0 KiB
// made by Tima // 2025 will be a golden year... //BREAK YOUR LIMITS!!!! #include "bits/stdc++.h" #define pii pair <int,int> #define all(x) x.begin() , x.end() #define pb push_back using namespace std; const int N = 2e5 + 5 , M = 5e6 + 5; const int mod = 1e9 + 7; const int INF = 1e9; int n,d,a[N],b[N],h[N],u,timer,root[M],val[N],tima; void init(int nn , int D , int H[]){ n = nn , d = D; for(int i = 0 ; i < nn ; i++){ h[i] = H[i]; } } map <pii,int> mp; set <int> t[35 * N]; struct nodee{ int l,r; }q[40 * N]; void build(int &v , int tl = 0 , int tr = u){ if(!v && tl == tr){ v = ++ tima; } if(!v) v = ++ timer; if(tl == tr){ return; } int tm = tl + tr >> 1; build(q[v].l , tl , tm); build(q[v].r , tm + 1 , tr); } void upd(int nv , int &v , int a , int b , int tl = 0 , int tr = u){ if(!v && tl == tr){ v = ++ tima; } if(!v) v = ++ timer; if(tl == tr){ t[v] = t[nv]; if(b < 0){ b = abs(b); t[v].erase(b); } else{ t[v].insert(b); } return; } int tm = tl + tr >> 1; if(a <= tm){ q[v].r = q[nv].r; upd(q[nv].l , q[v].l , a , b , tl , tm); } else{ q[v].l = q[nv].l; upd(q[nv].r , q[v].r , a , b , tm + 1 , tr); } } set <int> get(int v , int pos , int tl = 0 , int tr = u){ if(tl == tr){ return t[v]; } int tm = tl + tr >> 1; if(pos <= tm){ return get(q[v].l , pos , tl , tm); } else{ return get(q[v].r , pos , tm + 1 , tr); } } void curseChanges(int U, int A[], int B[]){ u = U; mp.clear(); int cnt = 0; build(root[0]); for(int i = 0 ; i < U ; i++){ a[i] = A[i] , b[i] = B[i]; mp[{min(a[i] , b[i]) , max(a[i] , b[i])}] ^= 1; if(mp[{min(a[i] , b[i]) , max(a[i] , b[i])}]){ cnt++; upd(root[cnt - 1] , root[cnt] , a[i] , b[i]); cnt++; upd(root[cnt - 1] , root[cnt] , b[i] , a[i]); } else{ cnt++; upd(root[cnt - 1] , root[cnt] , a[i] , -b[i]); cnt++; upd(root[cnt - 1] , root[cnt] , b[i] , -a[i]); } val[i] = cnt; } } int question(int X, int Y, int V){ int x = X , y = Y; int ans = 1e9; vector <int> q1 , q2; if(!V){ return 1e9; } for(auto it : get(root[val[V - 1]] , X)){ q1.pb(h[it]); // cout << it << ' '; } for(auto it : get(root[val[V - 1]] , Y)){ q2.pb(h[it]); } int j = 0; sort(all(q1)); sort(all(q2)); for(int i = 0 ; i < q1.size() ; i++){ while(j < q2.size()){ ans = min(ans , abs(q1[i] - q2[j])); if(q1[i] >= q2[j]){ j++; } else{ break; } } } return ans; } signed main() { int N, D, U, Q; std::ios::sync_with_stdio(false); std::cin.tie(NULL); std::cin >> N >> D >> U >> Q; int *F = new int[N]; for (int i=0; i<N; i++) std::cin >> F[i]; init(N, D, F); int *A = new int[U], *B = new int[U]; for (int i=0; i<U; i++) { std::cin >> A[i] >> B[i]; } curseChanges(U, A, B); bool correct = true; for (int i=0; i<Q; i++) { int X,Y,V,CorrectAnswer; std::cin >> X >> Y >> V >> CorrectAnswer; int YourAnswer = question(X,Y,V); // cout << X << ' ' << Y << ' ' << V << '\n'; if (YourAnswer != CorrectAnswer) { std::cout << "WA! Question: " << i << '\n' << "(X=" << X << ", Y=" << Y << ", V=" << V << ") \n" << "Your ans: " << YourAnswer << '\n' << "Correct Ans: " << CorrectAnswer << std::endl; correct = false; cout << "\n\n\n"; } else { std::cerr << YourAnswer << " - OK" << std::endl; } } if (correct) { std::cout << "Correct." << std::endl; } else std::cout << "Incorrect." << std::endl; return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccF53xCc.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccYxt7YB.o:potion.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status