제출 #1159132

#제출 시각아이디문제언어결과실행 시간메모리
1159132aligay100infaThe Potion of Great Power (CEOI20_potion)C++20
0 / 100
3044 ms327680 KiB
#include <bits/stdc++.h> using namespace std; namespace { const int N = 1e5 + 3; int n, d, m, h[N], a[N], b[N]; map <pair<int, int>, bool> g; } void swap(int &a, int &b) { a = a ^ b; b = a ^ b; a = a ^ b; } int min(int x, int y) { if (x < y) return x; return y; } int max(int x, int y) { if (x > y) return x; return y; } void init(int N, int D, int H[]) { n = N; d = D; for (int i = 1; i <= n; i++) { h[i] = H[i - 1]; } } void curseChanges(int U, int A[], int B[]) { m = U; for (int i = 1; i <= m; i++) { a[i] = A[i - 1] + 1; b[i] = B[i - 1] + 1; if (a[i] > b[i]) swap(a[i], b[i]); } } int question(int x, int y, int v) { x++; y++; set <int> s; for (int i = 1; i <= v; i++) g[{a[i], b[i]}] ^= 1; for (int i = 1; i <= n; i++) if (g[{min(i, y), max(i, y)}]) { s.insert(h[i]); // cout << y << ' ' << i << '\n'; } int ans = 1e9; for (int i = 1; i <= n; i++) if (g[{min(i, x), max(i, x)}]) { // cout << x << ' ' << i << '\n'; auto cur = s.lower_bound(h[i]); if (cur != s.end()) ans = min(ans, abs(h[i] - *cur)); if (cur == s.begin()) continue; cur--; ans = min(ans, abs(h[i] - *cur)); } for (int i = 1; i <= v; i++) g[{a[i], b[i]}] ^= 1; 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...