Submission #881922

# Submission time Handle Problem Language Result Execution time Memory
881922 2023-12-02T09:05:19 Z dosts Energetic turtle (IZhO11_turtle) C++17
40 / 100
133 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
const int N = 1e5+1,inf = 1e18;
int MOD;
int add(int x,int y) {return (x+y>=MOD?x+y-MOD:x+y);}
void solve() {
  int n,m,k,t;
  cin >> n >> m >> k >> t >> MOD;
  n++;
  m++;
  int dp[n+1][m+1][t+1];
  memset(dp,0,sizeof dp);
  int blocked[n+1][m+1];
  memset(blocked,0,sizeof blocked);
  for (int i=1;i<=k;i++) {
    int x,y;
    cin >> x >> y;
    x++;
    y++;
    blocked[x][y] = 1;
  } 
  dp[1][1][0] = 1;
  for (int i=1;i<=n;i++) {
    for (int j=1;j<=m;j++) {
      for (int p=0;p<=t;p++) {
        if (blocked[i-1][j]){
          if (p) dp[i][j][p] = add(dp[i][j][p],dp[i-1][j][p-1]);
        } 
        else {
          dp[i][j][p] = add(dp[i][j][p],dp[i-1][j][p]);
        }
        if (blocked[i][j-1]) {
          if (p) dp[i][j][p] = add(dp[i][j][p],dp[i][j-1][p-1]);
        }
        else {
          dp[i][j][p] = add(dp[i][j][p],dp[i][j-1][p]);
        }
      }
    }
  }
  int ans =0 ;
  for (int i=0;i<=t;i++) ans = add(ans,dp[n][m][i]);
  cout << ans << endl;
}	
    
                  
                             
signed main() { 
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  #ifdef Local
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int t = 1;
  //cin >> t;
	F(i,t) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 420 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 4 ms 5212 KB Output is correct
6 Correct 14 ms 16228 KB Output is correct
7 Correct 36 ms 44368 KB Output is correct
8 Correct 58 ms 71156 KB Output is correct
9 Runtime error 123 ms 262144 KB Execution killed with signal 9
10 Runtime error 133 ms 262144 KB Execution killed with signal 9
11 Runtime error 123 ms 262144 KB Execution killed with signal 9
12 Runtime error 124 ms 262144 KB Execution killed with signal 9
13 Runtime error 123 ms 262144 KB Execution killed with signal 9
14 Runtime error 121 ms 262144 KB Execution killed with signal 9
15 Runtime error 122 ms 262144 KB Execution killed with signal 9
16 Runtime error 122 ms 262144 KB Execution killed with signal 9
17 Runtime error 124 ms 262144 KB Execution killed with signal 9
18 Runtime error 124 ms 262144 KB Execution killed with signal 9
19 Runtime error 126 ms 262144 KB Execution killed with signal 9
20 Runtime error 124 ms 262144 KB Execution killed with signal 9