Submission #2866

#TimeUsernameProblemLanguageResultExecution timeMemory
2866ladown21간선 파괴 (GA5_destroy)C++98
25 / 100
2424 ms1364 KiB
#include <stdio.h> struct Edge{int a,b;}; Edge inner(int a,int b) {Edge r={a,b};return r;} int ufind(int k, int *T) { if (T[k] == k) return k; return T[k] = ufind(T[k], T); } int main() { int V,E,Q; scanf("%d%d",&V,&E); Edge G[50010]; int u,v; for (int i=1; i<=E; i++) { scanf("%d%d",&u,&v); G[i] = inner(u,v); } scanf("%d",&Q); while (Q--) { int T[510]={0}, a,b; for (int i=1; i<=V; i++) T[i] = i; scanf("%d%d",&a,&b); for (int i=1; i<=E; i++) { if (a<=i && i<=b) continue; int x = ufind(G[i].a, T); int y = ufind(G[i].b, T); T[x] = y; } for (int i=1; i<=V; i++) ufind(i,T); int C[800]={0}, ret=0; for (int i=1; i<=V; i++) ret += (C[T[i]]++)==0; printf("%d\n",ret); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...