Submission #958513

# Submission time Handle Problem Language Result Execution time Memory
958513 2024-04-05T22:58:29 Z YassirSalama Network (BOI15_net) C++17
0 / 100
5 ms 12380 KB
#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
#define OVL(x,s) for(auto y:x) cout<<y<<s; cout<<"\n";
#ifdef IOI
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
#else
#define dbg(...) 1337;
#endif
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define ll long long
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define int long long
const int MAXN=5e5+100;
vector<int> v[MAXN];
vector<pair<int,int>> op;
signed main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
for(int i=1;i<n;i++){
	int a,b;
	cin>>a>>b;
	v[a].pb(b);v[b].pb(a);
}
vector<int> lf;
for(int i=1;i<=n;i++){
    if(v[i].size()==1){
    	lf.pb(i);
    }
}
cout<<(lf.size()/2)+lf.size()%2<<endl;
// OVL(lf," ")
for(int i=0;i+1<lf.size();i+=2){
	cout<<lf[i]<<" "<<lf[i+1]<<endl;
}
if(lf.size()%2){
	cout<<lf[0]<<" "<<lf[lf.size()-1]<<endl;
}

}

Compilation message

net.cpp: In function 'int main()':
net.cpp:40:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 | for(int i=0;i+1<lf.size();i+=2){
      |             ~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 12124 KB Output is correct
2 Correct 5 ms 12380 KB Output is correct
3 Correct 3 ms 12124 KB Output is correct
4 Correct 3 ms 12120 KB Output is correct
5 Correct 3 ms 12124 KB Output is correct
6 Correct 3 ms 12124 KB Output is correct
7 Correct 3 ms 12124 KB Output is correct
8 Correct 3 ms 12124 KB Output is correct
9 Correct 4 ms 12120 KB Output is correct
10 Incorrect 3 ms 12124 KB Breaking single line is causing network to disconnect.
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 12124 KB Output is correct
2 Correct 5 ms 12380 KB Output is correct
3 Correct 3 ms 12124 KB Output is correct
4 Correct 3 ms 12120 KB Output is correct
5 Correct 3 ms 12124 KB Output is correct
6 Correct 3 ms 12124 KB Output is correct
7 Correct 3 ms 12124 KB Output is correct
8 Correct 3 ms 12124 KB Output is correct
9 Correct 4 ms 12120 KB Output is correct
10 Incorrect 3 ms 12124 KB Breaking single line is causing network to disconnect.
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 12124 KB Output is correct
2 Correct 5 ms 12380 KB Output is correct
3 Correct 3 ms 12124 KB Output is correct
4 Correct 3 ms 12120 KB Output is correct
5 Correct 3 ms 12124 KB Output is correct
6 Correct 3 ms 12124 KB Output is correct
7 Correct 3 ms 12124 KB Output is correct
8 Correct 3 ms 12124 KB Output is correct
9 Correct 4 ms 12120 KB Output is correct
10 Incorrect 3 ms 12124 KB Breaking single line is causing network to disconnect.
11 Halted 0 ms 0 KB -