Submission #1159253

#TimeUsernameProblemLanguageResultExecution timeMemory
1159253timoniThe Potion of Great Power (CEOI20_potion)C++20
0 / 100
3093 ms49772 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; set <int> st[N]; map <pii,int> mp; void init(int nn , int D , int H[]){ 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; mp.clear(); for(int i = 0 ; i < U ; i++){ a[i] = A[i] , b[i] = B[i]; } for(int i = 0 ; i < U ; 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])}]){ st[a[i]].insert(b[i]); st[b[i]].insert(a[i]); } else{ st[a[i]].erase(b[i]); st[b[i]].erase(a[i]); } } } int question(int X, int Y, int V){ int x = X , y = Y; int ans = 1e9; vector <int> q1 , q2; // return ans; set <int> st1 , st2; for(auto it : st[x]){ st1.insert(h[it]); } for(auto it : st[y]){ st2.insert(h[it]); } for(auto it : st[x]){ auto ti = st2.lower_bound(h[it]); if(ti != st2.end()){ ans = min(ans , abs(h[it] - (*ti))); } } for(auto it : st[y]){ auto ti = st1.lower_bound(h[it]); if(ti != st1.end()){ ans = min(ans , abs(h[it] - (*ti))); } } 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...