#include<bits/stdc++.h>
using namespace std;
int n, d, X[100010], i, j, u, Nei[100010], Nei0[100010], Nei1[100010];
set<pair<int, int> >nei[100010], nei0[100010], nei1[100010];
set<pair<int, int> >::iterator it, it2;
set<int>adj[100010];
void init(int N, int D, int H[])
{
n=N;
d=D;
for(i=0;i<n;i++)X[i]=H[i];
}
void curseChanges(int U, int A[], int B[])
{
u=U;
for(i=0;i<u;i++)
{
if(adj[A[i]].find(B[i])==adj[A[i]].end())
{
adj[A[i]].insert(B[i]);
adj[B[i]].insert(A[i]);
Nei[A[i]]++;
if(Nei[A[i]]==1)
{
nei[A[i]].insert({i, 1});
}
if(X[B[i]]==0)
{
Nei0[A[i]]++;
if(Nei0[A[i]]==1)
{
nei0[A[i]].insert({i, 1});
}
}
else
{
Nei1[A[i]]++;
if(Nei1[A[i]]==1)
{
nei1[A[i]].insert({i, 1});
}
}
Nei[B[i]]++;
if(Nei[B[i]]==1)
{
nei[B[i]].insert({i, 1});
}
if(X[A[i]]==0)
{
Nei0[B[i]]++;
if(Nei0[B[i]]==1)
{
nei0[B[i]].insert({i, 1});
}
}
else
{
Nei1[B[i]]++;
if(Nei1[B[i]]==1)
{
nei1[B[i]].insert({i, 1});
}
}
}
else
{
adj[A[i]].erase(B[i]);
adj[B[i]].erase(A[i]);
Nei[A[i]]--;
if(Nei[A[i]]==0)
{
nei[A[i]].insert({i, 0});
}
if(X[B[i]]==0)
{
Nei0[A[i]]--;
if(Nei0[A[i]]==0)
{
nei0[A[i]].insert({i, 0});
}
}
else
{
Nei1[A[i]]--;
if(Nei1[A[i]]==0)
{
nei1[A[i]].insert({i, 0});
}
}
Nei[B[i]]--;
if(Nei[B[i]]==0)
{
nei[B[i]].insert({i, 0});
}
if(X[A[i]]==0)
{
Nei0[B[i]]--;
if(Nei0[B[i]]==0)
{
nei0[B[i]].insert({i, 0});
}
}
else
{
Nei1[B[i]]--;
if(Nei1[B[i]]==0)
{
nei1[B[i]].insert({i, 0});
}
}
}
}
}
int question(int x, int y, int v)
{
v--;
it=nei[x].lower_bound({v, 2});
if(it==nei[x].begin())
{
return 1e9;
}
it--;
if(it->second==0)
{
return 1e9;
}
it=nei[y].lower_bound({v, 2});
if(it==nei[y].begin())
{
return 1e9;
}
it--;
if(it->second==0)
{
return 1e9;
}
bool x0=false, x1=false, y0=false, y1=false;
it=nei0[x].lower_bound({v, 2});
if(it==nei0[x].begin());
else
{
it--;
if(it->second==1)x0=true;
}
it=nei1[x].lower_bound({v, 2});
if(it==nei1[x].begin());
else
{
it--;
if(it->second==1)x1=true;
}
it=nei0[y].lower_bound({v, 2});
if(it==nei0[y].begin());
else
{
it--;
if(it->second==1)y0=true;
}
it=nei1[y].lower_bound({v, 2});
if(it==nei1[y].begin());
else
{
it--;
if(it->second==1)y1=true;
}
if((x0&&y0)||(x1&&y1))return 0;
else return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
19180 KB |
Incorrect |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
19308 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
333 ms |
50356 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
408 ms |
54176 KB |
Output is correct |
2 |
Correct |
280 ms |
39788 KB |
Output is correct |
3 |
Correct |
420 ms |
46068 KB |
Output is correct |
4 |
Correct |
437 ms |
46060 KB |
Output is correct |
5 |
Correct |
412 ms |
53612 KB |
Output is correct |
6 |
Correct |
423 ms |
46060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
21100 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
19180 KB |
Incorrect |