#include<stdio.h>
//for 60point code;
int edge[550][550],V,E,r,l,q;
int check[550];
void DFS(int x)
{
check[x]=q+1;
int i;
for(i=1;i<=V;i++){
if(check[i]!=q+1&&edge[x][i]&&(edge[x][i]<l||edge[x][i]>r))DFS(i);
}
}
void solve()
{
int i,ret=0;
for(i=1;i<=V;i++){
if(check[i]!=q+1){ret++;DFS(i);}
}
printf("%d\n",ret);
}
int main()
{
scanf("%d%d",&V,&E);
int i;
for(i=1;i<=E;i++){
int x,y;
scanf("%d%d",&x,&y);
edge[x][y]=edge[y][x]=i;
}
scanf("%d",&q);
while(q--){
scanf("%d%d",&l,&r);
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2272 KB |
Output is correct |
2 |
Correct |
0 ms |
2272 KB |
Output is correct |
3 |
Correct |
0 ms |
2272 KB |
Output is correct |
4 |
Correct |
0 ms |
2272 KB |
Output is correct |
5 |
Correct |
4 ms |
2272 KB |
Output is correct |
6 |
Correct |
0 ms |
2272 KB |
Output is correct |
7 |
Correct |
4 ms |
2272 KB |
Output is correct |
8 |
Correct |
0 ms |
2272 KB |
Output is correct |
9 |
Correct |
0 ms |
2272 KB |
Output is correct |
10 |
Correct |
4 ms |
2272 KB |
Output is correct |
11 |
Correct |
0 ms |
2272 KB |
Output is correct |
12 |
Correct |
4 ms |
2272 KB |
Output is correct |
13 |
Correct |
0 ms |
2272 KB |
Output is correct |
14 |
Correct |
0 ms |
2272 KB |
Output is correct |
15 |
Correct |
4 ms |
2272 KB |
Output is correct |
16 |
Correct |
0 ms |
2272 KB |
Output is correct |
17 |
Correct |
4 ms |
2272 KB |
Output is correct |
18 |
Correct |
0 ms |
2272 KB |
Output is correct |
19 |
Correct |
0 ms |
2272 KB |
Output is correct |
20 |
Correct |
4 ms |
2272 KB |
Output is correct |
21 |
Correct |
0 ms |
2272 KB |
Output is correct |
22 |
Correct |
0 ms |
2272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
704 ms |
2272 KB |
Output is correct |
2 |
Correct |
652 ms |
2272 KB |
Output is correct |
3 |
Correct |
724 ms |
2272 KB |
Output is correct |
4 |
Correct |
632 ms |
2272 KB |
Output is correct |
5 |
Correct |
580 ms |
2272 KB |
Output is correct |
6 |
Execution timed out |
2500 ms |
2272 KB |
Program timed out |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
2268 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |