Submission #764944

# Submission time Handle Problem Language Result Execution time Memory
764944 2023-06-24T06:50:14 Z vjudge1 Network (BOI15_net) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
	int n;
	cin>>n;
	bool t[n][n];
	memset(t, 0, sizeof t);
	
	for(int i = 0; i<n-1; i++){
		int x, y;
		cin>>x>>y;
		t[x-1][y-1]=1;
		t[y-1][x-1]=1;
	}
	vector<int>one;
	for(int i = 0; i<n; i++){
		int cnt=0;
		for(int j = 0; j<n; j++){
			if(t[i][j]==1) cnt++;
			if(cnt>=2){
				j=n-1;
				continue;
			}
		}
		if(cnt<2) one.pb(i+1);
	}
	int s = one.size()/2+one.size()%2;
	cout<<s<<'\n';
	for(int i = 0; i<one.size()/2; i++){
		
		cout<<one[i*2]<<' '<<one[i*2+1]<<'\n';
	}
	if(s%2!=0) cout<<one[one.size()-1]<<' '<<one[0];
	

}

Compilation message

net.cpp: In function 'int main()':
net.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = 0; i<one.size()/2; i++){
      |                 ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Extra information in the output file
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Extra information in the output file
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Extra information in the output file
2 Halted 0 ms 0 KB -