답안 #1055801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055801 2024-08-13T05:39:28 Z 김은성(#11066) Summer Driving (CCO24_day1problem3) C++17
1 / 25
132 ms 58964 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[300009];
int par[300009], depth[300009];
vector<int> child[300009];
void settree(int v){
	for(int u: graph[v]){
		if(par[v] == u)
			continue;
		par[u] = v;
		child[v].push_back(u);
		depth[u] = depth[v] + 1;
		settree(u);
	}
}
int main(){
	int n, r, a, b, i, u, v;
	scanf("%d %d %d %d", &n, &r, &a, &b);
	if(a <= b){
		printf("1\n");
		return 0;
	}
	for(i=1; i<n; i++){
		scanf("%d %d", &u, &v);
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	settree(r);
	for(i=1; i<=n; i++){
		if(a-b <= depth[i]%a){
			printf("%d\n", i);
			return 0;
		}
	}
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d %d %d %d", &n, &r, &a, &b);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%d %d", &u, &v);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 14428 KB Output is correct
2 Correct 5 ms 14500 KB Output is correct
3 Correct 5 ms 14428 KB Output is correct
4 Correct 4 ms 14428 KB Output is correct
5 Correct 5 ms 14428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 132 ms 58964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 14428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 14428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 20060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 14428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 14428 KB Output is correct
2 Correct 5 ms 14500 KB Output is correct
3 Correct 5 ms 14428 KB Output is correct
4 Correct 4 ms 14428 KB Output is correct
5 Correct 5 ms 14428 KB Output is correct
6 Incorrect 132 ms 58964 KB Output isn't correct
7 Halted 0 ms 0 KB -