답안 #873228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
873228 2023-11-14T16:39:48 Z VahanAbraham 힘 센 거북 (IZhO11_turtle) C++14
5 / 100
11 ms 14680 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <cmath>
#include <vector>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;

#define ll long long
#define fr first
#define sc second
#define pb push_back
#define US freopen("milkvisits.in", "r", stdin); freopen("milkvisits.out", "w", stdout);

ll gcd(ll a, ll b)
{
    if (a == 0 || b == 0) {
        return  max(a, b);
    }
    if (a <= b) {
        return gcd(a, b % a);
    }
    else {
        return gcd(a % b, b);
    }
}
ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}

const int N = 300005;
const ll oo = 1000000000000000, MOD = 998244353;

pair<ll, ll> p[N];
bool bl[1005][1005];
int dp[3][10003][21];

void solve() {
    int n, m, k, t;
    ll mod;
    cin >> n >> m >> k >> t >> mod;
    for (int i = 1; i <= k; ++i) {
        cin >> p[i].fr >> p[i].sc;
        bl[p[i].fr+1][p[i].sc+1] = 1;
    }
    dp[1][1][0] = 1;
    for (int i = 1; i <= n+1; ++i) {
        for (int j = 1; j <= m+1; j++) {
            for (int cnt = 0+bl[i][j]; cnt <= t-bl[i][j]; ++cnt) {
                dp[2][j][cnt] += dp[1][j][cnt - bl[i][j]], dp[i][j][cnt] %= mod;
                dp[2][j][cnt] += dp[2][j-1][cnt - bl[i][j]], dp[i][j][cnt] %= mod;
            }
        }
        for (int j = 1; j <= m + 1; j++) {
            for (int cnt = 0; cnt <= t; ++cnt) {
                dp[1][j][cnt] = dp[2][j][cnt];
                dp[2][j][cnt] = 0;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i <= t; ++i) {
        ans += dp[1][m+1][i], ans %= mod;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //US
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 4440 KB Output isn't correct
3 Runtime error 4 ms 8792 KB Execution killed with signal 11
4 Runtime error 5 ms 8796 KB Execution killed with signal 11
5 Runtime error 6 ms 9052 KB Execution killed with signal 11
6 Runtime error 6 ms 9156 KB Execution killed with signal 11
7 Runtime error 5 ms 9052 KB Execution killed with signal 11
8 Runtime error 5 ms 9560 KB Execution killed with signal 11
9 Runtime error 11 ms 14680 KB Execution killed with signal 11
10 Runtime error 3 ms 4700 KB Execution killed with signal 11
11 Runtime error 3 ms 4700 KB Execution killed with signal 11
12 Runtime error 3 ms 4700 KB Execution killed with signal 11
13 Runtime error 3 ms 4700 KB Execution killed with signal 11
14 Runtime error 2 ms 4520 KB Execution killed with signal 11
15 Runtime error 4 ms 4700 KB Execution killed with signal 11
16 Runtime error 2 ms 4700 KB Execution killed with signal 11
17 Runtime error 2 ms 4700 KB Execution killed with signal 11
18 Runtime error 2 ms 4700 KB Execution killed with signal 11
19 Runtime error 2 ms 4700 KB Execution killed with signal 11
20 Runtime error 2 ms 4700 KB Execution killed with signal 11