#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int NMAX = 100001;
const int VMAX = 101;
const int INF = 2e9;
const int MOD = 1000000007;
const int BLOCK = 447;
const int base = 117;
const int nr_of_bits = 24;
const int inv2 = 500000004;
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, -1, 1};
int R, C;
bool OK(int i, int j){
if(i < 1 || j < 1 || i > R || j > C)
return 0;
return 1;
}
void add(int &x, int val){
x = (1LL * x + 1LL * val) % MOD;
}
pii cnt[101][101][101];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int q;
cin >> R >> C >> q;
for(int i = 1; i <= C; i++){
queue <pii> q;
q.push({1, i});
cnt[i][1][i] = {0, 1};
while(q.size()){
pii x = q.front();
q.pop();
for(int d = 0; d < 8; d++){
int ni = x.first + dx[d];
int nj = x.second + dy[d];
if(!OK(ni, nj)) continue;
if(cnt[i][ni][nj].second == 0){
q.push({ni, nj});
cnt[i][ni][nj] = cnt[i][x.first][x.second];
add(cnt[i][ni][nj].first, 1);
}else if(cnt[i][ni][nj].first == cnt[i][x.first][x.second].first + 1){
add(cnt[i][ni][nj].second, cnt[i][x.first][x.second].second);
}
}
}
}
while(q--) {
int c1, cR;
char T;
cin >> T;
cin >> c1 >> cR;
cout << cnt[c1][R][cR].first << " " << cnt[c1][R][cR].second << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2772 KB |
Output is correct |
2 |
Correct |
47 ms |
8256 KB |
Output is correct |
3 |
Correct |
38 ms |
7436 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2772 KB |
Output is correct |
2 |
Correct |
47 ms |
8256 KB |
Output is correct |
3 |
Correct |
38 ms |
7436 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
5 |
Correct |
6 ms |
2816 KB |
Output is correct |
6 |
Correct |
3 ms |
1256 KB |
Output is correct |
7 |
Correct |
38 ms |
7488 KB |
Output is correct |
8 |
Correct |
46 ms |
8276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2772 KB |
Output is correct |
2 |
Correct |
47 ms |
8256 KB |
Output is correct |
3 |
Correct |
38 ms |
7436 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
5 |
Correct |
6 ms |
2816 KB |
Output is correct |
6 |
Correct |
3 ms |
1256 KB |
Output is correct |
7 |
Correct |
38 ms |
7488 KB |
Output is correct |
8 |
Correct |
46 ms |
8276 KB |
Output is correct |
9 |
Runtime error |
25 ms |
16632 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2772 KB |
Output is correct |
2 |
Correct |
47 ms |
8256 KB |
Output is correct |
3 |
Correct |
38 ms |
7436 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
5 |
Correct |
6 ms |
2816 KB |
Output is correct |
6 |
Correct |
3 ms |
1256 KB |
Output is correct |
7 |
Correct |
38 ms |
7488 KB |
Output is correct |
8 |
Correct |
46 ms |
8276 KB |
Output is correct |
9 |
Runtime error |
25 ms |
16632 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |