답안 #1055816

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055816 2024-08-13T05:48:57 Z 변재우(#11070) Summer Driving (CCO24_day1problem3) C++17
1 / 25
78 ms 22332 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int Nmax=300010;
int N, R, A, B, ans=Nmax, X[Nmax];
vector<int> adj[Nmax];

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>R>>A>>B;
    if(A<=B) {
        cout<<1; return 0;
    }
    for(int i=1; i<N; i++) {
        int u, v; cin>>u>>v;
        adj[u].push_back(v), adj[v].push_back(u);
    }
    X[1]=R;
    for(int i=1; i<N; i++) X[i+1]=(X[i-1]==adj[X[i]][0])?adj[X[i]][1]:adj[X[i]][0];
    for(int i=A+1; i<=N; i+=A) {
        for(int j=i-1; j>=i-B; j--) ans=min(ans, X[j]);
    }
    for(int i=((N-1)/A)*A+1; i<=min(N, ((N-1)/A)*A+1+B); i++) ans=min(ans, X[i]);
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7256 KB Output is correct
2 Correct 2 ms 7260 KB Output is correct
3 Correct 3 ms 7512 KB Output is correct
4 Correct 3 ms 7260 KB Output is correct
5 Correct 3 ms 7260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 19028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 14684 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 14684 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 22332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 14684 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7256 KB Output is correct
2 Correct 2 ms 7260 KB Output is correct
3 Correct 3 ms 7512 KB Output is correct
4 Correct 3 ms 7260 KB Output is correct
5 Correct 3 ms 7260 KB Output is correct
6 Incorrect 78 ms 19028 KB Output isn't correct
7 Halted 0 ms 0 KB -