Submission #1159233

#TimeUsernameProblemLanguageResultExecution timeMemory
1159233timoniThe Potion of Great Power (CEOI20_potion)C++20
17 / 100
3057 ms23876 KiB
// made by Tima // 2025 will be a golden year... //BREAK YOUR LIMITS!!!! #include "bits/stdc++.h" #define pii pair <int,int> using namespace std; const int N = 3e5 + 5; const int mod = 1e9 + 7; const int INF = 1e9; int n,d,a[N],b[N],h[N],u; vector <int> g[N]; map <pii,int> mp; void init(int nn , int D , int H[]){ for(int i = 0 ; i <= nn ; i++) g[i].clear(); n = nn , d = D; for(int i = 0 ; i < nn ; i++){ h[i] = H[i]; } } void curseChanges(int U, int A[], int B[]){ u = U; for(int i = 0 ; i < U ; i++){ a[i] = A[i] , b[i] = B[i]; } } int question(int X, int Y, int V){ mp.clear(); int x = X , y = Y; set <int> st1 , st2; for(int i = 0 ; i < V ; 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])}]){ if(a[i] == X){ st1.insert(b[i]); } if(a[i] == Y){ st2.insert(b[i]); } if(b[i] == X){ st1.insert(a[i]); } if(b[i] == Y){ st2.insert(a[i]); } } else{ if(a[i] == X){ st1.erase(b[i]); } if(a[i] == Y){ st2.erase(b[i]); } if(b[i] == X){ st1.erase(a[i]); } if(b[i] == Y){ st2.erase(a[i]); } } } int ans = 1e9; for(auto it : st1){ for(auto ti : st2){ // cout << it << ' ' << ti << '\n'; ans = min(abs(h[it] - h[ti]) , ans); } } 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; // } else { // std::cerr << YourAnswer << " - OK" << std::endl; // } // } // // if (correct) { // std::cout << "Correct." << std::endl; // } else std::cout << "Incorrect." << std::endl; // return 0; // }
#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...