# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
764879 | 2023-06-24T06:11:01 Z | vjudge1 | Network (BOI15_net) | C++17 | 2 ms | 2656 KB |
#pragma GCC optimize("Ofast") #pragma GCC target("avx","avx2","fma") #pragma GCC Optimization("unroll-loops") #pragma ("reroll") #include <bits/stdc++.h> #define ll long long using namespace std; const int maxn=1e5+9; const long long inf=1e15; const int mod=1e9+7; vector<int>g[maxn]; bool used[maxn]; int in[maxn]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); // #endif // 24.06.2023 // Iseque int n; cin>>n; for(int i=1;i<n;i++){ int u,v; cin>>u>>v; g[u].push_back(v); in[v]++; g[v].push_back(u); in[u]++; } int cnt=0; vector<pair<int,int>>v; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(in[i]==1&&g[j].size()==1&&g[j][1]!=i&&i!=j) { cnt++; v.push_back({i,j}); g[j].push_back(i); g[i].push_back(j); in[i]++; in[j]++; } } } cout<<cnt<<'\n'; for(int i=0;i<v.size();i++){ cout<<v[i].first<<' '<<v[i].second<<'\n'; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 1 ms | 2656 KB | Output is correct |
4 | Incorrect | 2 ms | 2644 KB | Invalid number of links. |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 1 ms | 2656 KB | Output is correct |
4 | Incorrect | 2 ms | 2644 KB | Invalid number of links. |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 1 ms | 2656 KB | Output is correct |
4 | Incorrect | 2 ms | 2644 KB | Invalid number of links. |
5 | Halted | 0 ms | 0 KB | - |