# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
2688 |
2013-07-30T15:22:32 Z |
ainta |
간선 파괴 (GA5_destroy) |
C++ |
|
760 ms |
2060 KB |
#include<stdio.h>
int n,m,b[700],e[700],Q,p[700],c;
struct Edge{
int a,b;
}E[123457];
void init(){
int i;
for(i=1;i<=n;i++)p[i]=i;
}
int find(int a){
if(a==p[a])return a;
return p[a]=find(p[a]);
}
int main(){
int i,j,x,y,R;
scanf("%d%d",&n,&m);
init();
for(i=0;i<m;i++){
scanf("%d%d",&E[i].a,&E[i].b);
x=find(E[i].a),y=find(E[i].b);
if(x!=y){
p[x]=y;
b[c++]=i;
}
}
init();
c=0;
for(i=m-1;i>=0;i--){
x=find(E[i].a),y=find(E[i].b);
if(x!=y){
p[x]=y;
e[c++]=i;
}
}
scanf("%d",&Q);
while(Q--){
scanf("%d%d",&x,&y);
x--,y--;
init();
R=n;
for(i=0;i<c;i++){
if(b[i]>=x)break;
x=find(E[b[i]].a),y=find(E[b[i]].b);
p[x]=y;
R--;
}
for(i=0;i<c;i++){
if(e[i]<=y)break;
x=find(E[b[i]].a),y=find(E[b[i]].b);
if(x!=y)p[x]=y,R--;
}
printf("%d\n",R);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2060 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
2060 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
760 ms |
2060 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |