Submission #7033397


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, M;
vector<int> E[101010];
int col[101010];
//---------------------------------------------------------------------------------------------------
int dp[101010];
void dfs(int cu, int pa = -1) {
    if(col[cu]) dp[cu] = 1;

    fore(to, E[cu]) if(to != pa) {
        dfs(to, cu);
        dp[cu] += dp[to];
    }
}
//---------------------------------------------------------------------------------------------------
bool ans = true;
void dfs2(int cu, int pa = -1) {
    int cnt = 0;
    fore(to, E[cu]) if(0 < dp[to]) cnt++;
    if(2 < cnt) ans = false;

    int tot = 0;
    fore(to, E[cu]) tot += dp[to];
    fore(to, E[cu]) if(to != pa) {
        dp[cu] = tot - dp[to];
        if(col[cu]) dp[cu]++;
        dfs2(to, cu);
    }
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, N - 1) {
        int a, b; cin >> a >> b;
        a--; b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    rep(i, 0, M) {
        int c; cin >> c; c--;
        col[c] = 1;
    }

    dfs(0);
    dfs2(0);

    if (ans) cout << "Yes" << endl;
    else cout << "trumpet" << endl;
}





Submission Info

Submission Time
Task B - Stalker
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2431 Byte
Status AC
Exec Time 53 ms
Memory 9728 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 200 / 200 200 / 200
Status
AC × 3
AC × 40
AC × 61
Set Name Test Cases
Sample sample01.txt, sample02.txt, sample03.txt
Subtask1 sample01.txt, sample02.txt, sample03.txt, one01.txt, one02.txt, one03.txt, one04.txt, one05.txt, one06.txt, one07.txt, one08.txt, one09.txt, one10.txt, one11.txt, one12.txt, one13.txt, one14.txt, one15.txt, one16.txt, one17.txt, one18.txt, one19.txt, one20.txt, one21.txt, one22.txt, hand01.txt, hand02.txt, hand03.txt, hand04.txt, hand05.txt, hand06.txt, hand07.txt, hand08.txt, hand09.txt, hand10.txt, hand11.txt, hand12.txt, hand13.txt, hand14.txt, hand15.txt
Subtask2 sample01.txt, sample02.txt, sample03.txt, one01.txt, one02.txt, one03.txt, one04.txt, one05.txt, one06.txt, one07.txt, one08.txt, one09.txt, one10.txt, one11.txt, one12.txt, one13.txt, one14.txt, one15.txt, one16.txt, one17.txt, one18.txt, one19.txt, one20.txt, one21.txt, one22.txt, hand01.txt, hand02.txt, hand03.txt, hand04.txt, hand05.txt, hand06.txt, hand07.txt, hand08.txt, hand09.txt, hand10.txt, hand11.txt, hand12.txt, hand13.txt, hand14.txt, hand15.txt, case01.txt, case02.txt, case03.txt, case04.txt, case05.txt, case06.txt, case07.txt, case08.txt, case09.txt, case10.txt, case11.txt, case12.txt, case13.txt, case14.txt, case15.txt, case16.txt, case17.txt, case18.txt, case19.txt, case20.txt, case21.txt
Case Name Status Exec Time Memory
case01.txt AC 53 ms 6656 KB
case02.txt AC 26 ms 4608 KB
case03.txt AC 45 ms 6272 KB
case04.txt AC 40 ms 9728 KB
case05.txt AC 21 ms 6144 KB
case06.txt AC 39 ms 9728 KB
case07.txt AC 44 ms 6272 KB
case08.txt AC 6 ms 3072 KB
case09.txt AC 44 ms 6272 KB
case10.txt AC 45 ms 6272 KB
case11.txt AC 45 ms 6272 KB
case12.txt AC 7 ms 3072 KB
case13.txt AC 6 ms 3072 KB
case14.txt AC 44 ms 6272 KB
case15.txt AC 6 ms 3072 KB
case16.txt AC 3 ms 2688 KB
case17.txt AC 53 ms 6656 KB
case18.txt AC 49 ms 6656 KB
case19.txt AC 45 ms 6656 KB
case20.txt AC 52 ms 6656 KB
case21.txt AC 45 ms 6272 KB
hand01.txt AC 3 ms 2688 KB
hand02.txt AC 3 ms 2688 KB
hand03.txt AC 3 ms 2688 KB
hand04.txt AC 3 ms 2688 KB
hand05.txt AC 3 ms 2688 KB
hand06.txt AC 3 ms 2688 KB
hand07.txt AC 3 ms 2688 KB
hand08.txt AC 3 ms 2688 KB
hand09.txt AC 3 ms 2688 KB
hand10.txt AC 3 ms 2688 KB
hand11.txt AC 3 ms 2688 KB
hand12.txt AC 3 ms 2688 KB
hand13.txt AC 3 ms 2688 KB
hand14.txt AC 3 ms 2688 KB
hand15.txt AC 3 ms 2688 KB
one01.txt AC 3 ms 2688 KB
one02.txt AC 4 ms 2688 KB
one03.txt AC 4 ms 2688 KB
one04.txt AC 4 ms 2688 KB
one05.txt AC 3 ms 2688 KB
one06.txt AC 4 ms 2816 KB
one07.txt AC 4 ms 2816 KB
one08.txt AC 3 ms 2688 KB
one09.txt AC 3 ms 2688 KB
one10.txt AC 3 ms 2688 KB
one11.txt AC 3 ms 2688 KB
one12.txt AC 3 ms 2688 KB
one13.txt AC 3 ms 2688 KB
one14.txt AC 3 ms 2688 KB
one15.txt AC 4 ms 2688 KB
one16.txt AC 3 ms 2688 KB
one17.txt AC 3 ms 2688 KB
one18.txt AC 3 ms 2688 KB
one19.txt AC 3 ms 2688 KB
one20.txt AC 4 ms 2688 KB
one21.txt AC 3 ms 2688 KB
one22.txt AC 3 ms 2688 KB
sample01.txt AC 3 ms 2688 KB
sample02.txt AC 3 ms 2688 KB
sample03.txt AC 3 ms 2688 KB