This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, h[maxn];
void init(int N, int D, int H[])
{
for (int i = 0; i < N; i ++)
{
h[i] = H[i];
}
}
const int maxq = 50010;
pair < int, int > edge[maxq];
void curseChanges(int U, int A[], int B[])
{
for (int i = 0; i < U; i ++)
{
edge[i] = {A[i], B[i]};
}
}
int question(int x, int y, int v)
{
set < int > sx, sy;
for (int i = 0; i < v; i ++)
{
int a = edge[i].first;
int b = edge[i].second;
if (a == x)
{
if (sx.find(b) == sx.end())
sx.insert(b);
else
sx.erase(b);
}
if (b == x)
{
if (sx.find(a) == sx.end())
sx.insert(a);
else
sx.erase(a);
}
if (a == y)
{
if (sy.find(b) == sy.end())
sy.insert(b);
else
sy.erase(b);
}
if (b == y)
{
if (sy.find(a) == sy.end())
sy.insert(a);
else
sy.erase(a);
}
}
if (sx.empty() && sy.empty())
return 1e9;
/**cout << "--------------" << endl;
for (int a : sx)
cout << a << " ";
cout << endl;
for (int b : sy)
cout << b << " ";
cout << endl;*/
int ans = 1e9;
for (int a : sx)
for (int b : sy)
ans = min(ans, abs(h[a] - h[b]));
return ans;
}
/**
6 5 11 4
2 42 1000 54 68 234
0 1
2 0
3 4
3 5
3 5
1 3
5 3
0 5
3 0
1 3
3 5
0 3 4
3 0 8
0 5 5
3 0 11
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |