Submission #769002

#TimeUsernameProblemLanguageResultExecution timeMemory
769002boyliguanhanThe Potion of Great Power (CEOI20_potion)C++17
0 / 100
3024 ms31456 KiB
#include<bits/stdc++.h> #pragma GCC optimize(2) #define NN 100100 using namespace std; int h[NN], n; unordered_set<int> adj[NN]; void init(int N, int D, int H[]) { n = N; for(int i = 0; i < N; i++) h[i] = H[i]; } void curseChanges(int U, int A[], int B[]) { for(int i = 1; i <= U; i++) { int a= A[i-1], b = B[i-1]; if(adj[a].count(b)) adj[a].erase(b), adj[b].erase(a); else adj[a].insert(b), adj[b].insert(a); } } int calc(vector<int> a, vector<int> b){ int ans = 1e9; for(int i = 0, j = 0; i < (int)a.size()&&j < (int)b.size();i++) { if(a[i]>b[j]) swap(a, b), swap(i, j); if(j) ans=min(ans,(int)abs(a[i]-b[j-1])); ans = min(ans, abs(a[i] - b[j])); } return ans; } int question(int x, int y, int v) { unordered_set<int> a = adj[x], b = adj[y]; vector<int> c, d; for(auto i: a) c.push_back(h[i]); for(auto i: b) d.push_back(h[i]); sort(c.begin(), c.end()); sort(d.begin(), d.end()); return calc(c,d); }
#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...