Submission #397012

#TimeUsernameProblemLanguageResultExecution timeMemory
397012The_BlitzNetwork (BOI15_net)C++17
0 / 100
1 ms304 KiB
// Restart // += O(logn) ; + = O(n) //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update #define fastio ios_base::sync_with_stdio(0);cin.tie(0) #define fst first #define snd second #define all(x) (x).begin(), (x).end() #define pb push_back #define sz size() #define FORN(i,j,n) for(int i=j; i<(int)n;i++) #define FOR(i,n) FORN(i,0,n) #define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ ) #define MOD 998244353LL #define MOD1 1000000007LL #define LIM 262150 #define ones(x) __builtin_popcount(x) #define trace(x) cerr << #x << ": " << x << endl; #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl; #define trace3(x, y,z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl; #define INF 1000000000 #define in(x) cin>>x; #define out(x) cout<<x; #define MAXIMO 1LL<<60 #define loga2(x) __builtin_ctzll(x) //SOLO PARA POTENCIAS DE 2 using namespace std; using namespace __gnu_pbds; typedef long long ll ; typedef unsigned long long ull ; typedef vector <int> vi; typedef pair <int,int> ii; typedef pair <int,ii> iii; typedef vector <string> vs; typedef vector <ii> vii; typedef vector <iii> viii; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; int degree[500005] = {0}; int v[500005] = {0}; set<int> ans; vi v1; vi v2; vi v3; void go(){ int n; cin>>n; for(int i=1; i<n;i++){ int x, y; cin >> x >> y; v[x] = y; v[y] = x; degree[x]++; degree[y]++; } for(int i=1; i<=n;i++){ if(degree[i] == 1) ans.insert(i); } cout<< (ans.size() + 1)/2 <<"\n"; for(int i=1; i<=n;i++){ if(ans.count(i)){ if(degree[i] == 1 && degree[v[i]] == 1){ v1.pb(i); v2.pb(v[i]); ans.erase(v[i]); } else v3.pb(i); ans.erase(i); } } for( int i =0 ; i<v1.size() ; i++){ swap(v3[i], v2[i]); cout<<v1[i]<<" "<<v2[i] << "\n"; } for( int i =0 ; i<(v3.size() + 1)/2 ; i++){ cout<<v3[i]<<" "<<v3[i + v3.size()/2] << "\n"; } } void timer(){ clock_t begin = clock(); go(); clock_t end = clock(); double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; cout<<time_spent<<"\n"; } int main() { //fastio; go(); //timer(); return 0; }

Compilation message (stderr)

net.cpp: In function 'void go()':
net.cpp:85:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |  for( int i =0 ; i<v1.size() ; i++){
      |                  ~^~~~~~~~~~
net.cpp:90:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |  for( int i =0 ; i<(v3.size() + 1)/2 ; i++){
      |                  ~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...