Submission #764879

#TimeUsernameProblemLanguageResultExecution timeMemory
764879vjudge1Network (BOI15_net)C++17
0 / 100
2 ms2656 KiB
#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 (stderr)

net.cpp:3: warning: ignoring '#pragma GCC Optimization' [-Wunknown-pragmas]
    3 | #pragma GCC Optimization("unroll-loops")
      | 
net.cpp:4: warning: ignoring '#pragma ( ' [-Wunknown-pragmas]
    4 | #pragma ("reroll")
      | 
net.cpp: In function 'int main()':
net.cpp:49:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |        for(int i=0;i<v.size();i++){
      |                    ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...