이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,bo[2009][2009],pas;
void ADD(int q, int w){
bo[q][w]=1;pas++;
if(bo[w][q]==1){
for(int h=1; h<=a; h++){
if(h==q||h==w) continue;
if(bo[h][q]==0&&bo[h][w]==1){
ADD(h,q);
continue;
}
if(bo[h][w]==0&&bo[h][q]==1){
ADD(h,q);
continue;
}
}
}
for(int h=1; h<=a; h++){
if(h==q||h==w) continue;
if(bo[h][w]==1&&bo[w][h]==1&&bo[q][h]==0){
ADD(q,h);
}
}
}
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>b;
for(i=1; i<=b; i++){
cin>>c>>d;
if(bo[c][d]==0) ADD(c,d);
cout<<pas<<"\n";
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |