Submission #960042

# Submission time Handle Problem Language Result Execution time Memory
960042 2024-04-09T14:57:12 Z ramalzaher Network (BOI15_net) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set ;
#define int long long
#define F first
#define S second
#define rep(i , j , n ) for(int i = j ;i < n; i++ )
#define FOR(i , n ) rep(i ,0 , n )
#define sz size()
#define pb push_back
#define all(x) x.begin() , x.end()
#define vi vector<int>
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define cans cout<<ans<<endl;
#define forx(i, x) for(auto &i : x)
#define fast
#define pii pair<int ,int >
#define endl "\n"
#define sp ' '
#define test int t ; cin >> t ; while(t--)
const int N = 300 ;
const int inf = 1e15 ;

int n ;

main()
{

cin >> n ;
vi v[n+22] ;
FOR(i ,n-1 ) {
int a , b; cin >> a >> b;
v[a].pb(b) ;
v[b].pb(a) ;
}
vi leaves ;
    rep(i , 1 , n + 1 ) {
    if(v[i].sz == 1 ) {
        leaves.pb(i) ;
    }
    }
    int ans = leaves.sz+1 ;
    ans/=2 ; cout<<ans<<endl;
    int sz1 = leaves.sz ;
//    leaves.pb();
    if(sz1&1){while(1)}
    FOR(i , sz1 ) {
    cout<<leaves[i]<<" " << leaves[i+1] << endl;
    i ++ ;
    }

//    if(sz1&1)cout<<leaves[sz1-1] << " " << leaves[0]<<endl;

return 0 ;
}

Compilation message

net.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main()
      | ^~~~
net.cpp: In function 'int main()':
net.cpp:48:23: error: expected primary-expression before '}' token
   48 |     if(sz1&1){while(1)}
      |                       ^