Submission #303100

# Submission time Handle Problem Language Result Execution time Memory
303100 2020-09-19T22:09:25 Z ly20 Mousetrap (CEOI17_mousetrap) C++17
0 / 100
454 ms 71220 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1123456;
int resp[MAXN];
vector <int> grafo[MAXN];
void dfs(int v, int p) {
	int mx = 0;
	for(int i = 0; i < grafo[v].size(); i++) {
		int viz = grafo[v][i];
		if(viz == p) continue;
		dfs(viz, v);
		resp[v] += resp[viz] + 1;
		mx = max(mx, resp[viz] + 1);
	}
	resp[v] -= mx;
}
int main() {
	int n, t, m;
	scanf("%d %d %d", &n, &t, &m);
	for(int i = 0; i < n - 1; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		grafo[a].push_back(b); grafo[b].push_back(a);
	}
	dfs(m, t);
	printf("%d\n", resp[m]);
	return 0;
}

Compilation message

mousetrap.cpp: In function 'void dfs(int, int)':
mousetrap.cpp:8:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for(int i = 0; i < grafo[v].size(); i++) {
      |                 ~~^~~~~~~~~~~~~~~~~
mousetrap.cpp: In function 'int main()':
mousetrap.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%d %d %d", &n, &t, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mousetrap.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |   scanf("%d %d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 26752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 454 ms 71220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 26752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 26752 KB Output isn't correct
2 Halted 0 ms 0 KB -