Submission #1230039

#TimeUsernameProblemLanguageResultExecution timeMemory
1230039GrayThe Potion of Great Power (CEOI20_potion)C++20
0 / 100
154 ms327680 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second vector<int> h; int n, mxd, d; vector<vector<set<int>>> A; void init(int N, int D, int H[]) { n=N; mxd=D; h.resize(n); for (ll i=0; i<n; i++) h[i]=H[i]; } void curseChanges(int U, int u[], int v[]) { A.resize(U+1, vector<set<int>>(n)); d=U; for (int i=0; i<U; i++){ A[i+1]=A[i]; if (A[i+1][u[i]].count(v[i])){ A[i+1][u[i]].erase(v[i]); A[i+1][v[i]].erase(u[i]); }else{ A[i+1][u[i]].insert(v[i]); A[i+1][v[i]].insert(u[i]); } } } int question(int x, int y, int v) { vector<int> hs; for (auto u:A[v][x]){ hs.push_back(h[u]); } if (hs.empty()) return 1e9; sort(hs.begin(), hs.end()); hs.erase(unique(hs.begin(), hs.end()), hs.end()); int mn=1e9; for (auto u:A[v][y]){ ll ind = lower_bound(hs.begin(), hs.end(), h[u])-hs.begin(); if (ind<(ll)hs.size()){ mn=min(mn, hs[ind]-h[u]); } if (ind){ mn=min(mn, h[u]-hs[ind-1]); } } return mn; }
#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...