답안 #249209

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
249209 2020-07-14T13:31:42 Z blacktulip Shell (info1cup18_shell) C++17
55 / 100
1000 ms 35252 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,dp[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 f(int sira,int gel){
	int cevv=0;
	if(sira==gel){
		//~ if(num<=k)return 0;
		return 1;
	}
	if(~dp[sira])return dp[sira];
	for(int i=0;i<(int)v[sira].size();i++){
		int go=v[sira][i];
		cevv=add(cevv,f(go,gel));
	}
	return dp[sira]=cevv;
}

inline int mul(int x,int y){
	return (x%mod)*(y%mod)%mod;
}

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]);
	}
	//~ sort(a+1,a+n+1);
	for(int i=1;i<=m;i++){
		int x,y;
		//~ if(vis[x][y])continue;
		scanf("%lld %lld",&x,&y);
		//~ v[x].pb(y);
		v[y].pb(x);
	}
	a[0]=1;
	a[k+1]=n;
	cev=1;
	for(int i=1;i<=k+1;i++){
		memset(dp,-1,sizeof(dp));
		cev=mul(cev,f(a[i],a[i-1]));
	}
	//~ cev=mul(cev,)
	printf("%lld\n",cev);
	return 0;
}

Compilation message

shell.cpp:53:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
shell.cpp: In function 'int main()':
shell.cpp:55: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:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
shell.cpp:63:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&x,&y);
   ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 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 8 ms 12140 KB Output is correct
5 Correct 8 ms 12032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 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 8 ms 12140 KB Output is correct
5 Correct 8 ms 12032 KB Output is correct
6 Correct 8 ms 12032 KB Output is correct
7 Correct 37 ms 12544 KB Output is correct
8 Correct 27 ms 12288 KB Output is correct
9 Correct 30 ms 12672 KB Output is correct
10 Correct 41 ms 12672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 12160 KB Output is correct
2 Correct 389 ms 17460 KB Output is correct
3 Correct 178 ms 17400 KB Output is correct
4 Correct 115 ms 17532 KB Output is correct
5 Correct 205 ms 18552 KB Output is correct
6 Correct 433 ms 35252 KB Output is correct
7 Execution timed out 1090 ms 35192 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 7 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 8 ms 12140 KB Output is correct
5 Correct 8 ms 12032 KB Output is correct
6 Correct 8 ms 12032 KB Output is correct
7 Correct 37 ms 12544 KB Output is correct
8 Correct 27 ms 12288 KB Output is correct
9 Correct 30 ms 12672 KB Output is correct
10 Correct 41 ms 12672 KB Output is correct
11 Correct 9 ms 12160 KB Output is correct
12 Correct 389 ms 17460 KB Output is correct
13 Correct 178 ms 17400 KB Output is correct
14 Correct 115 ms 17532 KB Output is correct
15 Correct 205 ms 18552 KB Output is correct
16 Correct 433 ms 35252 KB Output is correct
17 Execution timed out 1090 ms 35192 KB Time limit exceeded