Submission #578088

#TimeUsernameProblemLanguageResultExecution timeMemory
578088amunduzbaevThe Potion of Great Power (CEOI20_potion)C++17
0 / 100
3037 ms37896 KiB
#include "bits/stdc++.h" using namespace std; #ifndef EVAL #include "grader.cpp" #endif #define ar array const int N = 1e5 + 5; vector<ar<int, 2>> edges[N]; set<int> S[N]; int h[N]; void init(int N, int D, int H[]) { for(int i=0;i<N;i++){ h[i] = H[i]; } } void curseChanges(int U, int A[], int B[]) { set<ar<int, 2>> ss; for(int i=0;i<U;i++){ if(A[i] > B[i]) swap(A[i], B[i]); int t = 1; if(ss.count({A[i], B[i]})) t = -1; if(t == 1){ S[A[i]].insert(B[i]); S[B[i]].insert(A[i]); } else { S[A[i]].erase(B[i]); S[B[i]].erase(A[i]); } //~ edges[A[i]].push_back({i + 1, (B[i] + 1) * t}); //~ edges[B[i]].push_back({i + 1, (A[i] + 1) * t}); if(t == 1) ss.insert({A[i], B[i]}); else ss.erase({A[i], B[i]}); } } int question(int x, int y, int v) { multiset<int> a, b; for(auto u : S[x]) a.insert(h[u]); for(auto u : S[y]) b.insert(h[u]); //~ cout<<"here"<<endl; //~ for(auto u : edges[x]){ //~ if(u[0] > v) break; //~ if(u[1] < 0){ //~ a.erase(a.find(h[-u[1] - 1])); //~ } else { //~ a.insert(h[u[1] - 1]); //~ } //~ } //~ for(auto u : edges[y]){ //~ if(u[0] > v) break; //~ if(u[1] < 0){ //~ b.erase(b.find(h[-u[1] - 1])); //~ } else { //~ b.insert(h[u[1] - 1]); //~ } //~ } int res = 1e9; for(auto x : a){ auto it = b.lower_bound(x); if(it != b.end()){ res = min(res, *it - x); } if(it != b.begin()){ it--; res = min(res, x - *it); } } return res; } /* 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 26 3 0 8 0 0 5 5 1000000000 3 0 11 14 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...