#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define ull unsigned ll
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
const ll m = (200000 / 50) + 5;
ll n,h[100005];
set<ll>exo[10005][50];
vector<ii>ar;
void init(int N, int D, int H[]){
n = N;
f(i,0,n){
h[i] = H[i];
}
}
void curseChanges(int U, int A[], int B[]) {
ll u = U;
set<ll>cur[n];
f(i,0,u){
ll a = A[i],b = B[i];
ar.pb({a,b});
if(!cur[a].count(b)){
cur[a].insert(b);
cur[b].insert(a);
}
else{
cur[a].erase(b);
cur[b].erase(a);
}
if((i + 1) % m == 0){
f(j,0,n){
exo[j][(i + 1) / m] = cur[j];
}
}
}
}
int question(int x, int y, int v) {
ll ans = 1e9;
ll cur = (v / m) * m;
set<ll>ex[2];
vector<ii>kame;
ex[0] = exo[x][cur / m];
ex[1] = exo[y][cur / m];
while(cur != v){
if(ar[cur].F == x){
if(ex[0].count(ar[cur].S)){
ex[0].erase(ar[cur].S);
}
else{
ex[0].insert(ar[cur].S);
}
}
if(ar[cur].S == x){
if(ex[0].count(ar[cur].F)){
ex[0].erase(ar[cur].F);
}
else{
ex[0].insert(ar[cur].F);
}
}
if(ar[cur].F == y){
if(ex[1].count(ar[cur].S)){
ex[1].erase(ar[cur].S);
}
else{
ex[1].insert(ar[cur].S);
}
}
if(ar[cur].S == y){
if(ex[1].count(ar[cur].F)){
ex[1].erase(ar[cur].F);
}
else{
ex[1].insert(ar[cur].F);
}
}
cur++;
}
f(i,0,2){
for(auto x:ex[i]){
kame.pb(ii(h[x],i));
}
}
sort(all(kame));
f(i,0,(ll)kame.size()-1){
if(kame[i].S != kame[i+1].S){
ans = min(ans,kame[i+1].F - kame[i].F);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23888 KB |
Output is correct |
2 |
Correct |
15 ms |
23888 KB |
Output is correct |
3 |
Correct |
14 ms |
23868 KB |
Output is correct |
4 |
Runtime error |
65 ms |
59360 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
95 ms |
63212 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
79 ms |
63224 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
232 ms |
26576 KB |
Output is correct |
2 |
Correct |
458 ms |
24680 KB |
Output is correct |
3 |
Execution timed out |
3032 ms |
24636 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23760 KB |
Output is correct |
2 |
Correct |
14 ms |
23888 KB |
Output is correct |
3 |
Correct |
15 ms |
23888 KB |
Output is correct |
4 |
Correct |
14 ms |
23868 KB |
Output is correct |
5 |
Runtime error |
65 ms |
59360 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |