Submission #45120

#TimeUsernameProblemLanguageResultExecution timeMemory
45120model_codeShell (info1cup18_shell)C++17
100 / 100
439 ms35248 KiB
#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 (stderr)

shell.cpp: In function 'int main()':
shell.cpp:44:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d %d", &n, &m, &p);
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
shell.cpp:52:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d", &v[i]);
         ~~~~~~^~~~~~~~~~~~~
shell.cpp:59:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d %d", &x, &y);
         ~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...