Submission #349824

# Submission time Handle Problem Language Result Execution time Memory
349824 2021-01-18T13:03:45 Z doowey Mousetrap (CEOI17_mousetrap) C++14
25 / 100
894 ms 69272 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)1e6 + 100;
vector<int> T[N];

int trap;
int mouse;

int dfs(int u, int par){
    vector<int> lis;
    for(auto x : T[u]){
        if(x==par) continue;
        lis.push_back(dfs(x,u));
    }
    sort(lis.begin(),lis.end());
    int mx = 0;
    if(lis.size() >= 2){
        mx = lis[lis.size() - 2];
    }
    return (int)lis.size() + mx;
}

int main(){
    fastIO;
    int n;
    cin >> n;
    cin >> trap >> mouse;
    int u, v;
    for(int i = 1; i < n; i ++ ){
        cin >> u >> v;
        T[u].push_back(v);
        T[v].push_back(u);
    }
    cout << dfs(mouse,trap);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 23820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 362 ms 55500 KB Output is correct
2 Correct 338 ms 52200 KB Output is correct
3 Correct 875 ms 56812 KB Output is correct
4 Correct 417 ms 40428 KB Output is correct
5 Correct 894 ms 69228 KB Output is correct
6 Correct 883 ms 69272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 23820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 23820 KB Output isn't correct
2 Halted 0 ms 0 KB -