# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
584967 |
2022-06-28T07:52:56 Z |
Newtech66 |
Network (BOI15_net) |
C++17 |
|
9 ms |
14036 KB |
#include<bits/stdc++.h>
using namespace std;
using lol=long long int;
#define endl "\n"
const lol mod1=1e9+7,mod2=998244353,mod3=1000000000000000003;
const lol inf=1e18+8;
const double eps=1e-12;
const double PI=acos(-1.0);
const int N=5e5+5;
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<vector<int>> g(N);
vector<int> deg(N,0);
vector<int> leaves;
vector<pair<int,int>> edges;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int _=1;
//cin>>_;
while(_--)
{
int n;
cin>>n;
for(int i=0;i<n-1;i++)
{
int u,v;
cin>>u>>v;
deg[u]++,deg[v]++;
}
for(int i=1;i<=n;i++)
{
if(deg[i]==1) leaves.push_back(i);
}
for(int i=0;i<(int)leaves.size()-1;i+=2)
{
edges.push_back({leaves[i],leaves[i+1]});
}
if((int)leaves.size()%2==1) edges.push_back({leaves[0],leaves.back()});
cout<<edges.size()<<endl;
for(auto [a,b]:edges) cout<<a<<" "<<b<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
13908 KB |
Output is correct |
2 |
Correct |
7 ms |
14036 KB |
Output is correct |
3 |
Correct |
9 ms |
14036 KB |
Output is correct |
4 |
Correct |
9 ms |
14036 KB |
Output is correct |
5 |
Correct |
9 ms |
13908 KB |
Output is correct |
6 |
Correct |
8 ms |
13908 KB |
Output is correct |
7 |
Correct |
7 ms |
13908 KB |
Output is correct |
8 |
Correct |
8 ms |
13908 KB |
Output is correct |
9 |
Correct |
7 ms |
13908 KB |
Output is correct |
10 |
Incorrect |
9 ms |
13908 KB |
Breaking single line is causing network to disconnect. |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
13908 KB |
Output is correct |
2 |
Correct |
7 ms |
14036 KB |
Output is correct |
3 |
Correct |
9 ms |
14036 KB |
Output is correct |
4 |
Correct |
9 ms |
14036 KB |
Output is correct |
5 |
Correct |
9 ms |
13908 KB |
Output is correct |
6 |
Correct |
8 ms |
13908 KB |
Output is correct |
7 |
Correct |
7 ms |
13908 KB |
Output is correct |
8 |
Correct |
8 ms |
13908 KB |
Output is correct |
9 |
Correct |
7 ms |
13908 KB |
Output is correct |
10 |
Incorrect |
9 ms |
13908 KB |
Breaking single line is causing network to disconnect. |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
13908 KB |
Output is correct |
2 |
Correct |
7 ms |
14036 KB |
Output is correct |
3 |
Correct |
9 ms |
14036 KB |
Output is correct |
4 |
Correct |
9 ms |
14036 KB |
Output is correct |
5 |
Correct |
9 ms |
13908 KB |
Output is correct |
6 |
Correct |
8 ms |
13908 KB |
Output is correct |
7 |
Correct |
7 ms |
13908 KB |
Output is correct |
8 |
Correct |
8 ms |
13908 KB |
Output is correct |
9 |
Correct |
7 ms |
13908 KB |
Output is correct |
10 |
Incorrect |
9 ms |
13908 KB |
Breaking single line is causing network to disconnect. |
11 |
Halted |
0 ms |
0 KB |
- |