#include <bits/stdc++.h>
using namespace std;
typedef pair<int,vector<int>> piv;
int n,h[100005];
vector<piv> v[100005];
void add(int x, int y, int t) { //add y to x
vector<int> temp;
if (find(v[x].back().second.begin(),v[x].back().second.end(),y)==v[x].back().second.end()) {
bool f=false;
for (auto s : v[x].back().second) {
if (h[s]<h[y]) temp.push_back(s);
else {
if (!f) {
temp.push_back(y);
temp.push_back(s);
f=true;
} else {
temp.push_back(s);
}
}
}
if (!f) temp.push_back(y);
} else {
for (auto s : v[x].back().second) {
if (s!=y) temp.push_back(s);
}
}
v[x].push_back(piv(t,temp));
}
void init(int N, int D, int H[]) {
n=N;
for (int i=0; i<n; ++i) h[i]=H[i], v[i].push_back(piv(0,{}));
}
void curseChanges(int U, int A[], int B[]) {
for (int i=0; i<U; ++i) {
add(A[i],B[i],i+1);
add(B[i],A[i],i+1);
}
}
int question(int x, int y, int day) {
int hx=upper_bound(v[x].begin(),v[x].end(),piv(day+1,{}))-v[x].begin()-1;
int hy=upper_bound(v[y].begin(),v[y].end(),piv(day+1,{}))-v[y].begin()-1;
int xi=0, yi=0, nx=v[x][hx].second.size(), ny=v[y][hy].second.size();
if (!nx || !ny) return 1e9;
else {
int ans=INT_MAX;
while (xi<nx && yi<ny) {
ans=min(ans,abs(h[v[x][hx].second[xi]]-h[v[y][hy].second[yi]]));
if (h[v[x][hx].second[xi]]>h[v[y][hy].second[yi]]) ++yi;
else ++xi;
}
return ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2896 KB |
Output is correct |
2 |
Correct |
2 ms |
2896 KB |
Output is correct |
3 |
Correct |
2 ms |
2896 KB |
Output is correct |
4 |
Correct |
18 ms |
8292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
41444 KB |
Output is correct |
2 |
Correct |
300 ms |
41456 KB |
Output is correct |
3 |
Correct |
212 ms |
42976 KB |
Output is correct |
4 |
Correct |
532 ms |
222868 KB |
Output is correct |
5 |
Correct |
288 ms |
62452 KB |
Output is correct |
6 |
Runtime error |
410 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
41412 KB |
Output is correct |
2 |
Runtime error |
306 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
4816 KB |
Output is correct |
2 |
Incorrect |
19 ms |
5124 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2640 KB |
Output is correct |
2 |
Correct |
2 ms |
2896 KB |
Output is correct |
3 |
Correct |
2 ms |
2896 KB |
Output is correct |
4 |
Correct |
2 ms |
2896 KB |
Output is correct |
5 |
Correct |
18 ms |
8292 KB |
Output is correct |
6 |
Correct |
278 ms |
41444 KB |
Output is correct |
7 |
Correct |
300 ms |
41456 KB |
Output is correct |
8 |
Correct |
212 ms |
42976 KB |
Output is correct |
9 |
Correct |
532 ms |
222868 KB |
Output is correct |
10 |
Correct |
288 ms |
62452 KB |
Output is correct |
11 |
Runtime error |
410 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |