Submission #337588

# Submission time Handle Problem Language Result Execution time Memory
337588 2020-12-21T07:17:36 Z tengiz05 Energetic turtle (IZhO11_turtle) C++17
10 / 100
2000 ms 262148 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define PI acos(-1)
#define ld long double
const int N = 2005;
int msb(int val){return sizeof(int)*8-__builtin_clzll(val);}
int n, m, k;
int dp[N][N][21];
int a[N][N];
int mod;
void solve(int test_case){
	int i, j, t;
	cin >> n >> m;
	cin >> k >> t >> mod;
	n++,m++;
	for(i=0;i<k;i++){
		int x, y;
		cin >> x >> y;
		x++,y++;
		a[x][y] = 1;
	}
	dp[1][0][0] = 1;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(a[i][j] == 0)
				for(int l=0;l<=t;l++){
					dp[i][j][l] = (dp[i-1][j][l] + dp[i][j-1][l])%mod;
				}
			else 
				for(int l=1;l<=t;l++){
					dp[i][j][l] = (dp[i-1][j][l-1]+dp[i][j-1][l-1])%mod;
				}
		}
	}
/*	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cout << dp[i][j][0] << ' ' ;
		}cout << '\n';
	}*/
	int ans = 0;
	for(i=0;i<=t;i++)ans += dp[n][m][i];
	cout << ans << '\n';
	
	return;
}

signed main(){
	FASTIO;
#define MULTITEST 0
#if MULTITEST
	int ___T;
	cin >> ___T;
	for(int T_CASE = 1; T_CASE <= ___T; T_CASE++)
		solve(T_CASE);
#else
	solve(1);
#endif
	return 0;
}




# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 1024 KB Output isn't correct
4 Incorrect 1 ms 1516 KB Output isn't correct
5 Incorrect 7 ms 5996 KB Output isn't correct
6 Incorrect 29 ms 43884 KB Output isn't correct
7 Incorrect 59 ms 69996 KB Output isn't correct
8 Incorrect 116 ms 169324 KB Output isn't correct
9 Runtime error 303 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 492 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Execution timed out 2055 ms 111468 KB Time limit exceeded
12 Execution timed out 2104 ms 85048 KB Time limit exceeded
13 Execution timed out 2084 ms 146540 KB Time limit exceeded
14 Execution timed out 2097 ms 122092 KB Time limit exceeded
15 Execution timed out 2085 ms 77304 KB Time limit exceeded
16 Execution timed out 2045 ms 147364 KB Time limit exceeded
17 Execution timed out 2101 ms 235832 KB Time limit exceeded
18 Execution timed out 2055 ms 116532 KB Time limit exceeded
19 Execution timed out 2095 ms 96416 KB Time limit exceeded
20 Execution timed out 2080 ms 71812 KB Time limit exceeded