# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
256016 |
2020-08-02T08:16:32 Z |
최은수(#5029) |
Joker (BOI20_joker) |
C++17 |
|
95 ms |
6768 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).fi==par(v).fi&&par(u).se!=par(v).se)
{
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).fi==par(v).fi&&par(u).se!=par(v).se)
{
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
95 ms |
5872 KB |
Output is correct |
4 |
Incorrect |
84 ms |
6768 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |