Submission #335282

# Submission time Handle Problem Language Result Execution time Memory
335282 2020-12-11T20:06:01 Z limabeans Energetic turtle (IZhO11_turtle) C++17
40 / 100
2000 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1010;


ll n,m,k,t,mod;

ll dp[maxn][maxn][22];
bool bad[maxn][maxn];


void add(ll &x, ll y) {
    x %= mod;
    y %= mod;
    x += y;
    x %= mod;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n>>m>>k>>t>>mod;

    while (k--) {
	int x,y;
	cin>>x>>y;
	bad[x][y]=1;
    }

    dp[0][0][t]=1;

    for (int i=0; i<=n; i++) {
	for (int j=0; j<=m; j++) {
	    for (int q=t; q>=(bad[i][j]?1:0); q--) {
		add(dp[i+1][j][q-bad[i][j]], dp[i][j][q]);
		add(dp[i][j+1][q-bad[i][j]], dp[i][j][q]);
	    }
	}
    }

    ll res=0;
    for (int q=0; q<=t; q++) {
	add(res,dp[n][m][q]);
    }

    cout<<res<<endl;    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 408 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 1004 KB Output is correct
4 Correct 3 ms 1536 KB Output is correct
5 Correct 23 ms 6252 KB Output is correct
6 Correct 85 ms 45804 KB Output is correct
7 Correct 219 ms 73324 KB Output is correct
8 Correct 371 ms 174740 KB Output is correct
9 Runtime error 1838 ms 262144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Execution timed out 2087 ms 122980 KB Time limit exceeded
11 Execution timed out 2045 ms 26288 KB Time limit exceeded
12 Execution timed out 2052 ms 54956 KB Time limit exceeded
13 Execution timed out 2069 ms 61380 KB Time limit exceeded
14 Execution timed out 2092 ms 26988 KB Time limit exceeded
15 Execution timed out 2092 ms 22976 KB Time limit exceeded
16 Execution timed out 2099 ms 58452 KB Time limit exceeded
17 Execution timed out 2094 ms 87208 KB Time limit exceeded
18 Execution timed out 2097 ms 58476 KB Time limit exceeded
19 Execution timed out 2102 ms 56300 KB Time limit exceeded
20 Execution timed out 2103 ms 53868 KB Time limit exceeded