# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
249189 | blacktulip | Shell (info1cup18_shell) | C++17 | 1097 ms | 43384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t,dp[1505][1505],vis[1505][1505];
int cev;
string s;
vector<int> v[li];
inline int add(int x,int y){
if(x+y>=mod)return x+y-mod;
return x+y;
}
inline int mul(int x,int y){
return (x%mod)*(y%mod)%mod;
}
inline int f(int sira,int num){
int cevv=0;
if(sira==n){
if(num<=k)return 0;
return 1;
}
if(~dp[sira][num])return dp[sira][num];
for(int i=0;i<(int)v[sira].size();i++){
int go=v[sira][i];
cevv=add(cevv,mul(f(go,num+(go==a[num]?1:0)),vis[sira][go]));
}
return dp[sira][num]=cevv;
}
main(void){
memset(dp,-1,sizeof(dp));
scanf("%lld %lld %lld",&n,&m,&k);
for(int i=1;i<=k;i++){
scanf("%lld",&a[i]);
}
for(int i=1;i<=m;i++){
int x,y;
scanf("%lld %lld",&x,&y);
if(vis[x][y]){vis[x][y]++;continue;}
v[x].pb(y);
vis[x][y]++;
}
printf("%lld\n",f(1,1+(a[1]==1?1:0)));
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |