#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<n; i++)
for (int j=0; j<n; j++)
for (int k=0; k<3*n; 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 |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |