Submission #134596

# Submission time Handle Problem Language Result Execution time Memory
134596 2019-07-23T05:16:32 Z Ace Network (BOI15_net) C++14
0 / 100
2 ms 380 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 5e5;

int n;
int ada[N+5];

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		ada[u]++;
		ada[v]++;
	}
	int cnt = 0;
	for(int i=1;i<=n;i++){
		if(ada[i] == 1) cnt++;
	}
	printf("%d\n",(cnt+1)/2);
	int bef = -1;
	for(int i=1;i<=n;i++){
		if(ada[i] == 1){
			if(bef == -1){
				bef = i;
			} else {
				printf("%d %d\n",i,bef);
				bef = -1;
			}
		}
	}
	if(bef!=-1){
		printf("%d 1\n",bef);
	}
	return 0;
}

Compilation message

net.cpp: In function 'int main()':
net.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
net.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&u,&v);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 2 ms 376 KB Breaking single line is causing network to disconnect.
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 2 ms 376 KB Breaking single line is causing network to disconnect.
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 2 ms 376 KB Breaking single line is causing network to disconnect.
11 Halted 0 ms 0 KB -