# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45120 | 2018-04-11T10:14:13 Z | model_code | Shell (info1cup18_shell) | C++17 | 439 ms | 35248 KB |
#include <cstdio> #include <algorithm> #include <vector> #include <cassert> #define MOD 1000000007LL using namespace std; int n, m, p; vector <int> g[1000010]; int dp[1000010], v[1000010]; long long nr[1000010]; void dfs (int nod) { if (nod == n) { dp[nod] = 1; nr[nod] = 1LL; if (nod == v[ p - dp[nod] + 1 ]) ++dp[nod]; return; } for (auto &it : g[nod]) { if (dp[it] == 0) dfs (it); if (dp[it] > dp[nod]) dp[nod] = dp[it], nr[nod] = nr[it]; else if (dp[it] == dp[nod]) nr[nod] += nr[it]; nr[nod] %= MOD; } if (nod == v[ p - dp[nod] + 1 ]) ++dp[nod]; } int main () { // freopen ("input", "r", stdin); // freopen ("output1", "w", stdout); scanf ("%d %d %d", &n, &m, &p); assert (1 <= n && n <= 1000000); // assert (1 <= m && m <= 1000000); assert (1 <= p && p <= 1000000); for (int i = 1; i <= p; ++i) { scanf ("%d", &v[i]); assert (1 <= v[i] && v[i] <= n); } for (int i = 1; i <= m; ++i) { int x, y; scanf ("%d %d", &x, &y); assert (1 <= x && x <= n); assert (1 <= y && y <= n); assert (x != y); g[x].push_back (y); } dfs (1); printf ("%lld\n", nr[1]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 23800 KB | Output is correct |
2 | Correct | 19 ms | 23800 KB | Output is correct |
3 | Correct | 19 ms | 23840 KB | Output is correct |
4 | Correct | 20 ms | 24020 KB | Output is correct |
5 | Correct | 22 ms | 24020 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 23800 KB | Output is correct |
2 | Correct | 19 ms | 23800 KB | Output is correct |
3 | Correct | 19 ms | 23840 KB | Output is correct |
4 | Correct | 20 ms | 24020 KB | Output is correct |
5 | Correct | 22 ms | 24020 KB | Output is correct |
6 | Correct | 21 ms | 24096 KB | Output is correct |
7 | Correct | 26 ms | 24224 KB | Output is correct |
8 | Correct | 25 ms | 24224 KB | Output is correct |
9 | Correct | 28 ms | 24240 KB | Output is correct |
10 | Correct | 28 ms | 24292 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 24292 KB | Output is correct |
2 | Correct | 141 ms | 26904 KB | Output is correct |
3 | Correct | 125 ms | 26904 KB | Output is correct |
4 | Correct | 120 ms | 26904 KB | Output is correct |
5 | Correct | 118 ms | 26904 KB | Output is correct |
6 | Correct | 251 ms | 30828 KB | Output is correct |
7 | Correct | 265 ms | 30868 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 23800 KB | Output is correct |
2 | Correct | 19 ms | 23800 KB | Output is correct |
3 | Correct | 19 ms | 23840 KB | Output is correct |
4 | Correct | 20 ms | 24020 KB | Output is correct |
5 | Correct | 22 ms | 24020 KB | Output is correct |
6 | Correct | 21 ms | 24096 KB | Output is correct |
7 | Correct | 26 ms | 24224 KB | Output is correct |
8 | Correct | 25 ms | 24224 KB | Output is correct |
9 | Correct | 28 ms | 24240 KB | Output is correct |
10 | Correct | 28 ms | 24292 KB | Output is correct |
11 | Correct | 21 ms | 24292 KB | Output is correct |
12 | Correct | 141 ms | 26904 KB | Output is correct |
13 | Correct | 125 ms | 26904 KB | Output is correct |
14 | Correct | 120 ms | 26904 KB | Output is correct |
15 | Correct | 118 ms | 26904 KB | Output is correct |
16 | Correct | 251 ms | 30828 KB | Output is correct |
17 | Correct | 265 ms | 30868 KB | Output is correct |
18 | Correct | 438 ms | 35248 KB | Output is correct |
19 | Correct | 439 ms | 35248 KB | Output is correct |
20 | Correct | 401 ms | 35248 KB | Output is correct |
21 | Correct | 173 ms | 35248 KB | Output is correct |
22 | Correct | 424 ms | 35248 KB | Output is correct |