Submission #588929

#TimeUsernameProblemLanguageResultExecution timeMemory
588929ArnchThe Potion of Great Power (CEOI20_potion)C++17
0 / 100
288 ms4468 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e3 + 10, maxn = 1e6 + 10; int n, d, h[maxn], a[maxn], b[maxn]; bool mark[maxn], mark2[maxn]; void init(int N, int D, int H[]) { n = N, d = D; for(int i = 0; i < n; i++) h[i] = H[i]; } void curseChanges(int U, int A[], int B[]) { for(int i = 0; i < U; i++) a[i] = A[i], b[i] = B[i]; } int question(int x, int y, int v) { set<int> stx, sty; for(int i = 0; i < v; i++) { if(a[i] == x && b[i] == y) return 0; if(b[i] == x && a[i] == y) return 0; if(b[i] == x) swap(a[i], b[i]); if(a[i] == x) { if(mark[b[i]]) { stx.erase(b[i]); mark[b[i]] = 0; } else { mark[b[i]] = 1; stx.insert(b[i]); } continue; } if(b[i] == y) swap(a[i], b[i]); if(a[i] == y) { if(mark2[b[i]]) { sty.erase(b[i]); mark2[b[i]] = 0; } else { mark2[b[i]] = 1; sty.insert(b[i]); } continue; } } for(int i = 0; i < v; i++) { mark[a[i]] = mark[b[i]] = 0; mark2[a[i]] = mark2[b[i]] = 0; } int ans = 1e9; for(auto it : stx) for(auto it2 : sty) { ans = min(ans, abs(it - it2)); } return ans; }
#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...