답안 #875027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
875027 2023-11-18T14:06:50 Z dilanyan 힘 센 거북 (IZhO11_turtle) C++17
40 / 100
181 ms 197348 KB
//-------------dilanyan------------\\ 
 
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;

//------------------KarginDefines--------------------\\ 

#define ll long long
#define pb push_back
#define all(u) (u).begin(), (u).end()
#define pqueue priority_queue
#define upper upper_bound
#define lower lower_bound
#define umap unordered_map
#define uset unordered_set
#define Kargin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Usaco freopen(".in", "r", stdin); freopen(".out", "w", stdout);


//-------------------KarginConstants------------------\\ 
 
const int mod = 1000000007;
const ll inf = 1e9;

//-------------------KarginCode------------------------\\ 
 
const int N = 1005;
bool a[N][N];
ll dp[N][N][25];

void KarginSolve() {
    ll n, m, k, t, z;
    cin >> n >> m >> k >> t >> z;
    for (int i = 0;i < k;i++) {
        int x, y;
        cin >> x >> y;
        a[x][y] = true;
    }
    dp[0][0][0] = 1;
    for (int b = 0;b <= k;b++) {
        for (int i = 0;i <= n;i++) {
            for (int j = 0;j <= n;j++) {
                if (!i && !j) continue;
                if (a[i][j]) {
                    if(!b) continue;
                    if (i > 0) dp[i][j][b] += dp[i - 1][j][b - 1];
                    if (j > 0) dp[i][j][b] += dp[i][j - 1][b - 1];
                }
                else {
                    if (i > 0) dp[i][j][b] += dp[i - 1][j][b];
                    if (j > 0) dp[i][j][b] += dp[i][j - 1][b];
                }
                dp[i][j][b] %= z;
            }
        }
    }
    ll ans = 0;
    for (int i = 0;i <= t;i++) {
        ans += dp[n][m][i];
        ans %= z;
    }
    cout << ans << '\n';
}

int main() {
    //Usaco
    Kargin;
    int test = 1;
    //cin >> test;
    while (test--) {
        KarginSolve();
    }
    return 0;
}

Compilation message

turtle.cpp:1:1: warning: multi-line comment [-Wcomment]
    1 | //-------------dilanyan------------\\
      | ^
turtle.cpp:8:1: warning: multi-line comment [-Wcomment]
    8 | //------------------KarginDefines--------------------\\
      | ^
turtle.cpp:22:1: warning: multi-line comment [-Wcomment]
   22 | //-------------------KarginConstants------------------\\
      | ^
turtle.cpp:27:1: warning: multi-line comment [-Wcomment]
   27 | //-------------------KarginCode------------------------\\
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 460 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 9 ms 9284 KB Output is correct
6 Correct 46 ms 51544 KB Output is correct
7 Correct 156 ms 129064 KB Output is correct
8 Correct 181 ms 197348 KB Output is correct
9 Runtime error 4 ms 604 KB Execution killed with signal 11
10 Runtime error 4 ms 528 KB Execution killed with signal 11
11 Runtime error 5 ms 348 KB Execution killed with signal 11
12 Runtime error 5 ms 604 KB Execution killed with signal 11
13 Runtime error 4 ms 604 KB Execution killed with signal 11
14 Runtime error 5 ms 348 KB Execution killed with signal 11
15 Runtime error 5 ms 604 KB Execution killed with signal 11
16 Runtime error 4 ms 464 KB Execution killed with signal 11
17 Runtime error 4 ms 472 KB Execution killed with signal 11
18 Runtime error 4 ms 604 KB Execution killed with signal 11
19 Runtime error 5 ms 604 KB Execution killed with signal 11
20 Runtime error 4 ms 348 KB Execution killed with signal 11