답안 #691000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
691000 2023-01-30T20:24:27 Z divad Shell (info1cup18_shell) C++14
10 / 100
77 ms 30872 KB
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 1000002
using namespace std;
int n,m,p,x,y,dp[MAX],cnt[MAX],mrc[MAX];
/// dp[nod] = in ce nod trebuie sa merg
/// cnt[nod] = cate drumuri sunt
vector<int> v[MAX];

void dfs(int nod){
    if(nod == n){
        dp[nod] = 1;
        cnt[nod] = 1;
        if(nod == mrc[p-dp[nod]+1]){
            dp[nod]++;
        }
    }else{
        for(int vecin: v[nod]){
            if(dp[vecin] == 0){
                dfs(vecin);
            }
            if(dp[vecin] > dp[nod]){
                dp[nod] = dp[vecin];
                cnt[nod] = cnt[vecin];
            }else if(dp[vecin] == dp[nod]){
                cnt[nod] += cnt[vecin];
            }
        }
        if(nod == mrc[p-dp[nod]+1]){
            dp[nod]++;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m >> p;
    for(int i = 1; i <= p; i++){
        cin >> mrc[i];
    }
    for(int i = 1; i <= m; i++){
        cin >> x >> y;
        v[x].push_back(y);
    }
    dfs(1);
    cout << cnt[1];
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23812 KB Output is correct
3 Correct 13 ms 23748 KB Output is correct
4 Correct 13 ms 23804 KB Output is correct
5 Correct 13 ms 23812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23812 KB Output is correct
3 Correct 13 ms 23748 KB Output is correct
4 Correct 13 ms 23804 KB Output is correct
5 Correct 13 ms 23812 KB Output is correct
6 Incorrect 13 ms 23816 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23892 KB Output is correct
2 Correct 73 ms 30756 KB Output is correct
3 Incorrect 77 ms 30872 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23812 KB Output is correct
3 Correct 13 ms 23748 KB Output is correct
4 Correct 13 ms 23804 KB Output is correct
5 Correct 13 ms 23812 KB Output is correct
6 Incorrect 13 ms 23816 KB Output isn't correct
7 Halted 0 ms 0 KB -