huangyiheng666 @ 2024-11-04 18:56:47
CCF和洛谷上的给出数据都过, 但都60pts, 测试点5 7 8 10挂。
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int n, m, k;
bool used[N][N], z[N][N];
int x, y, d;
char ch;
int go() {
memset(used, 0, sizeof used);
int res = 1;
used[x][y] = true;
for (int i = 1; i <= k; i++) {
int tx = x, ty = y;
if(d == 0)ty ++;
if(d == 1)tx ++;
if(d == 2)ty --;
if(d == 3)tx --;
if(z[tx][ty]) x = tx, y = ty;
else d = (d + 1) % 4;
if(!used[x][y])res ++;
used[x][y] = true;
}
return res;
}
int main() {
int T;
scanf("%d", &T);
while(T --) {
scanf("%d%d%d", &n, &m, &k);
scanf("%d%d%d", &x, &y, &d);
for (int i = 1; i <= n; i++) {
scanf("%c", &ch);
for (int j = 1; j <= m; j++) {
scanf("%c", &ch);
z[i][j] = ch == '.';
}
}
printf("%d\n", go());
}
return 0;
}
by Willson1307 @ 2024-11-04 20:04:57
@huangyiheng666 似乎是对的
by Willson1307 @ 2024-11-04 20:07:43
不是你不把 z 清空那不是小数据就判不了边界吗?你不要贪便宜
by hsyAKIOI @ 2024-11-04 20:08:56
我给你调A了
by hsyAKIOI @ 2024-11-04 20:09:13
@huangyiheng666
by huangyiheng666 @ 2024-11-04 21:45:05
@hsyAKIOI @Willson1307 谢谢