Submission #249258

# Submission time Handle Problem Language Result Execution time Memory
249258 2020-07-14T14:27:59 Z blacktulip Shell (info1cup18_shell) C++17
100 / 100
969 ms 63584 KB
#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;
int cev;
map<int,int> mpp;
string s;
map<pair<int,int>,int> dp;
vector<int> v[li];
 
inline int add(int x,int y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}
 
inline int f(int sira,int num){
	int cevv=0;
	if(sira==n){
		if(num<=k)return 0;
		return 1;
	}
	if(dp.find(mp(sira,num))!=dp.end())return dp[mp(sira,num)];
	for(int i=0;i<(int)v[sira].size();i++){
		int go=v[sira][i];
		if(mpp[go] && mpp[go]!=num)continue;
		cevv=add(cevv,f(go,num+(go==a[num]?1:0)));
	}
	return dp[mp(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]);
		mpp[a[i]]=i;
	}
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%lld %lld",&x,&y);
		v[x].pb(y);
	}
	printf("%lld\n",f(1,1+(a[1]==1?1:0)));
	return 0;
}

Compilation message

shell.cpp:52:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
shell.cpp: In function 'int main()':
shell.cpp:54:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld",&n,&m,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
shell.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
shell.cpp:61:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&x,&y);
   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 12032 KB Output is correct
2 Correct 7 ms 12032 KB Output is correct
3 Correct 7 ms 12032 KB Output is correct
4 Correct 7 ms 12032 KB Output is correct
5 Correct 7 ms 12032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 12032 KB Output is correct
2 Correct 7 ms 12032 KB Output is correct
3 Correct 7 ms 12032 KB Output is correct
4 Correct 7 ms 12032 KB Output is correct
5 Correct 7 ms 12032 KB Output is correct
6 Correct 8 ms 12160 KB Output is correct
7 Correct 18 ms 12800 KB Output is correct
8 Correct 13 ms 12544 KB Output is correct
9 Correct 28 ms 12928 KB Output is correct
10 Correct 24 ms 12800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12160 KB Output is correct
2 Correct 139 ms 21880 KB Output is correct
3 Correct 198 ms 22008 KB Output is correct
4 Correct 180 ms 22008 KB Output is correct
5 Correct 110 ms 16504 KB Output is correct
6 Correct 408 ms 25080 KB Output is correct
7 Correct 318 ms 24952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 12032 KB Output is correct
2 Correct 7 ms 12032 KB Output is correct
3 Correct 7 ms 12032 KB Output is correct
4 Correct 7 ms 12032 KB Output is correct
5 Correct 7 ms 12032 KB Output is correct
6 Correct 8 ms 12160 KB Output is correct
7 Correct 18 ms 12800 KB Output is correct
8 Correct 13 ms 12544 KB Output is correct
9 Correct 28 ms 12928 KB Output is correct
10 Correct 24 ms 12800 KB Output is correct
11 Correct 9 ms 12160 KB Output is correct
12 Correct 139 ms 21880 KB Output is correct
13 Correct 198 ms 22008 KB Output is correct
14 Correct 180 ms 22008 KB Output is correct
15 Correct 110 ms 16504 KB Output is correct
16 Correct 408 ms 25080 KB Output is correct
17 Correct 318 ms 24952 KB Output is correct
18 Correct 969 ms 63584 KB Output is correct
19 Correct 921 ms 58060 KB Output is correct
20 Correct 764 ms 44612 KB Output is correct
21 Correct 291 ms 24440 KB Output is correct
22 Correct 930 ms 49988 KB Output is correct