제출 #589814

#제출 시각아이디문제언어결과실행 시간메모리
589814piOOEThe Potion of Great Power (CEOI20_potion)C++17
14 / 100
786 ms40284 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int maxN = 100000, maxU = 200000, INF = 1000000000; int a[maxU], b[maxU], h[maxN], n, u, d; vector<int> g[maxN]; void init(int N, int D, int H[]) { n = N, d = D; memcpy(h, H, sizeof(h[0]) * n); } void curseChanges(int U, int A[], int B[]) { u = U; memcpy(a, A, sizeof(a[0]) * u), memcpy(b, B, sizeof(b[0]) * u); set<pair<int, int>> adj; for (int i = 0; i < u; ++i) { if (a[i] > b[i]) { swap(a[i], b[i]); } if (adj.count({a[i], b[i]})) { adj.erase({a[i], b[i]}); } else { adj.insert({a[i], b[i]}); } } for (auto [x, y]: adj) { g[x].push_back(y); g[y].push_back(x); } for (int i = 0; i < n; ++i) { sort(g[i].begin(), g[i].end(), [](int i, int j) { return h[i] < h[j]; }); } } int question(int x, int y, int v) { //i suppose that v == u assert(v == u); int ans = INF; for (int to : g[x]) { auto it = lower_bound(g[y].begin(), g[y].end(), to, [](int i, int j) { return h[i] < h[j]; }); if (it != g[y].end()) { ans = min(ans, h[*it] - h[to]); } if (it != g[y].begin()) { ans = min(ans, h[to] - h[*prev(it)]); } } 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...