# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
256015 |
2020-08-02T08:14:49 Z |
최은수(#5029) |
Joker (BOI20_joker) |
C++17 |
|
92 ms |
6568 KB |
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;
int pa[200010],pr[200010];
inline pi par(int x)
{
int y=0;
int z=x;
while(pa[z]!=0)
y^=pr[z],z=pa[z];
int w=y;
while(pa[x]!=0)
{
int nx=pa[x];
int nw=w^pr[w];
pa[x]=z;
pr[x]=w;
x=nx;
w=nw;
}
return pi(z,y);
}
inline void uni(int x,int y)
{
int odd=par(x).se^par(y).se;
x=par(x).fi;
y=par(y).fi;
if(x==y)
return;
pa[x]=y;
pr[x]=odd^1;
return;
}
inline void clear(int n)
{
fill(pa,pa+n+1,0);
return;
}
int ans[200010];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m,q;
cin>>n>>m>>q;
vector<pi>edge(m);
for(pi&t:edge)
cin>>t.fi>>t.se;
vector<pi>qv(q);
vector<int>cv;
for(pi&t:qv)
cin>>t.fi>>t.se,cv.eb(--t.fi);
sort(all(cv));
cv.erase(unique(all(cv)),cv.end());
for(int&cl:cv)
{
clear(n);
ans[cl]=-1;
for(int i=0;i<cl;i++)
{
int u=edge[i].fi,v=edge[i].se;
if(par(u)==par(v))
{
ans[cl]=m;
break;
}
uni(u,v);
}
if(ans[cl]!=-1)
continue;
for(int i=m;--i>cl;)
{
int u=edge[i].fi,v=edge[i].se;
if(par(u)==par(v))
{
ans[cl]=i;
break;
}
uni(u,v);
}
}
for(pi&t:qv)
cout<<(ans[t.fi]<t.se?"NO\n":"YES\n");
cout.flush();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
91 ms |
6000 KB |
Output is correct |
4 |
Correct |
92 ms |
6568 KB |
Output is correct |
5 |
Incorrect |
86 ms |
6512 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |