Submission #74776

# Submission time Handle Problem Language Result Execution time Memory
74776 2018-09-07T05:26:10 Z arman_ferdous Network (BOI15_net) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 5e5+10;
int n, d[N];
vector<int> g[N], leaf;

int main() {
	scanf("%d", &n);
	for(int i = 1; i < n; i++) {
		int u, v; scanf("%d %d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
		d[u]++, d[v]++;
	}
	for(int i = 1; i <= n; i++) if(d[i] == 1)
		leaf.push_back(i);

	int sz = leaf.size();
	printf("%d\n", (int)ceil(sz/2.));
	for(int i = 0; i < sz; i+=2) {
		if(i+1 < sz) printf("%d %d\n", leaf[i], leaf[i+1]);#include <bits/stdc++.h>
using namespace std;

const int N = 5e5+10;
int n, d[N];
vector<int> g[N], leaf;

int main() {
	scanf("%d", &n);
	for(int i = 1; i < n; i++) {
		int u, v; scanf("%d %d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
		d[u]++, d[v]++;
	}
	for(int i = 1; i <= n; i++) if(d[i] == 1)
		leaf.push_back(i);

	int sz = leaf.size();
	printf("%d\n", (int)ceil(sz/2.));
	for(int i = 0; i < sz; i+=2) {
		if(i+1 < sz) printf("%d %d\n", leaf[i], leaf[i+1]);
		else printf("%d %d\n", leaf[i], leaf[i-1]);
	} return 0;	
}
		else printf("%d %d\n", leaf[i], leaf[i-1]);
	} return 0;	
}

Compilation message

net.cpp:22:54: error: stray '#' in program
   if(i+1 < sz) printf("%d %d\n", leaf[i], leaf[i+1]);#include <bits/stdc++.h>
                                                      ^
net.cpp: In function 'int main()':
net.cpp:22:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if(i+1 < sz) printf("%d %d\n", leaf[i], leaf[i+1]);#include <bits/stdc++.h>
   ^~
net.cpp:22:55: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   if(i+1 < sz) printf("%d %d\n", leaf[i], leaf[i+1]);#include <bits/stdc++.h>
                                                       ^~~~~~~
net.cpp:22:55: error: 'include' was not declared in this scope
net.cpp:22:64: error: 'bits' was not declared in this scope
   if(i+1 < sz) printf("%d %d\n", leaf[i], leaf[i+1]);#include <bits/stdc++.h>
                                                                ^~~~
net.cpp:22:64: note: suggested alternative: 'puts'
   if(i+1 < sz) printf("%d %d\n", leaf[i], leaf[i+1]);#include <bits/stdc++.h>
                                                                ^~~~
                                                                puts
net.cpp:22:69: error: 'stdc' was not declared in this scope
   if(i+1 < sz) printf("%d %d\n", leaf[i], leaf[i+1]);#include <bits/stdc++.h>
                                                                     ^~~~
net.cpp:22:69: note: suggested alternative: 'stdin'
   if(i+1 < sz) printf("%d %d\n", leaf[i], leaf[i+1]);#include <bits/stdc++.h>
                                                                     ^~~~
                                                                     stdin
net.cpp:23:1: error: expected primary-expression before 'using'
 using namespace std;
 ^~~~~
net.cpp:29:12: error: a function-definition is not allowed here before '{' token
 int main() {
            ^
net.cpp:47:3: error: 'else' without a previous 'if'
   else printf("%d %d\n", leaf[i], leaf[i-1]);
   ^~~~
net.cpp:26:5: warning: unused variable 'n' [-Wunused-variable]
 int n, d[N];
     ^
net.cpp:26:8: warning: unused variable 'd' [-Wunused-variable]
 int n, d[N];
        ^
net.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
net.cpp:11:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int u, v; scanf("%d %d", &u, &v);
             ~~~~~^~~~~~~~~~~~~~~~~