# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
764919 | vjudge1 | Network (BOI15_net) | C++17 | 0 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e3;
bool used[N][N];
vector <int> g[N];
signed main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
int x,y;
cin>>x>>y;
x--;
y--;
used[x][y]=1;
used[y][x]=1;
g[x].push_back(y);
g[y].push_back(x);
}
vector <pair <int,int> > k;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
if(!used[i-1][j-1] and g[i-1].size()==1){
k.push_back(make_pair(i-1,j-1));
used[i-1][j-1]=1;
used[j-1][i-1]=1;
g[i-1].push_back(j-1);
g[j-1].push_back(i-1);
}
}
}
cout<<k.size()<<endl;
for(int i=0;i<k.size();i++){
cout<<k[i].first+1<<" "<<k[i].second+1<<endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |