Submission #213423

#TimeUsernameProblemLanguageResultExecution timeMemory
213423Haunted_CppShell (info1cup18_shell)C++17
0 / 100
1100 ms9216 KiB
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <cassert> #include <string> #include <cstring> #include <bitset> #define FOR(i, a, b) for(int i = a; i < (int) b; i++) #define F0R(i, a) FOR (i, 0, a) #define ROF(i, a, b) for(int i = a; i >= (int) b; i--) #define R0F(i, a) ROF(i, a, 0) #define GO(i, a) for (auto i : a) #define rsz resize #define eb emplace_back #define pb push_back #define sz(x) (int) x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define f first #define s second using namespace std; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vpii; typedef vector<vi> vvi; typedef vector<vpii> vvpii; typedef long long i64; typedef vector<i64> vi64; typedef vector<vi64> vvi64; typedef pair<i64, i64> pi64; typedef vector<pi64> vpi64; const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1}; const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1}; const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31}; const int N = 1500 + 5; const int M = 1500 + 5; const int MOD = 1e9 + 7; int n, m, k, streak [N]; int lvl [N], dp [N][M]; vvi g (N); void add (int &a, int b) { a += b; while (a >= MOD) a -= MOD; } void build (int node, int depth = 0) { lvl[node] = depth; GO (to, g[node]) { build (to, depth + 1); } } int solve (int node, int match) { if (node == n - 1) return (match == k); if (match < k && lvl[node] > lvl[streak[match]]) return 0; if (~dp[node][match]) return dp[node][match]; dp[node][match] = 0; int target = (match < k ? streak[match] : -1); GO (to, g[node]) add (dp[node][match], solve (to, match + (to == target))); return dp[node][match]; } int main () { scanf ("%d %d %d", &n, &m, &k); memset (dp, -1, sizeof(dp)); F0R (i, k) { scanf ("%d", &streak[i]); --streak[i]; } F0R (i, m) { int st, et; scanf ("%d %d", &st, &et); --st; --et; g[st].eb(et); } build (0); printf("%d\n", solve (0, streak[0] == 0 ? 1 : 0)); return 0; }

Compilation message (stderr)

shell.cpp: In function 'int main()':
shell.cpp:78:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d %d %d", &n, &m, &k);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
shell.cpp:81:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d", &streak[i]);
     ~~~~~~^~~~~~~~~~~~~~~~~~
shell.cpp:86:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &st, &et);
     ~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...