Submission #858174

# Submission time Handle Problem Language Result Execution time Memory
858174 2023-10-07T14:29:07 Z sofijavelkovska Chess Rush (CEOI20_chessrush) C++14
5 / 100
2000 ms 12124 KB
#include <bits/stdc++.h>
//#include "arithmetics.h";
using namespace std;

const int MOD=1e9+7, MAXN=100;

int m, n, s, e;
int memo[MAXN][MAXN][3*MAXN];
int adj[8][2]={{1,0},{0,1},{-1,0},{0,-1},{1,-1},{-1,1},{1,1},{-1,-1}};

int dp(int x, int y, int moves)
{
    if (x>=m || x<0 || y>=n || y<0)
        return 0;
    if (x==0 && y==s)
        return 1;
    if (moves==0)
        return 0;
    if (memo[x][y][moves]!=-1)
        return memo[x][y][moves];
    int total=0;
    for (int i=0; i<8; i++)
        total=(total+dp(x+adj[i][0], y+adj[i][1], moves-1))%MOD;

    return memo[x][y][moves]=total;
}

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

    int q;
    char type;
    cin >> m >> n >> q;
    while (q--)
    {
        cin >> type >> s >> e;
        s=s-1;
        e=e-1;
        if (s>e)
            swap(s, e);
        int w=e-s;
        int h=m-1-w;
        for (int i=0; i<m; i++)
            for (int j=0; j<n; j++)
                for (int k=0; k<m+n+10; k++)
                    memo[i][j][k]=-1;
        cout << w+h << " " << dp(m-1, e, w+h) << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 325 ms 11096 KB Output is correct
2 Correct 898 ms 12124 KB Output is correct
3 Correct 820 ms 11868 KB Output is correct
4 Correct 53 ms 10584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 325 ms 11096 KB Output is correct
2 Correct 898 ms 12124 KB Output is correct
3 Correct 820 ms 11868 KB Output is correct
4 Correct 53 ms 10584 KB Output is correct
5 Execution timed out 2063 ms 11212 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 325 ms 11096 KB Output is correct
2 Correct 898 ms 12124 KB Output is correct
3 Correct 820 ms 11868 KB Output is correct
4 Correct 53 ms 10584 KB Output is correct
5 Execution timed out 2063 ms 11212 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 325 ms 11096 KB Output is correct
2 Correct 898 ms 12124 KB Output is correct
3 Correct 820 ms 11868 KB Output is correct
4 Correct 53 ms 10584 KB Output is correct
5 Execution timed out 2063 ms 11212 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -