0826

已结束 IOI 开始于: 2026-8-26 19:00 2 小时 主持人: 2
#include <bits/stdc++.h>
using namespace std;
int nxt[4][2]={0,1,1,0,0,-1,-1,0};
char mat[1005][1005];
int book[1005][1005];
int main(){
	int T;
	cin>>T;
	while(T--){
		memset(book,0,sizeof(book));
		int sx,sy,d;
		int n,m,k;
		cin>>n>>m>>k;
		cin>>sx>>sy>>d;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				cin>>mat[i][j];
			}
		}
		book[sx][sy] = 1;
		int nowx=sx,nowy=sy,dir=d;
		while(k){
			int nx = nowx+nxt[dir][0],ny=nowy+nxt[dir][1];
			if(nx>=1 && nx<=n && ny>=1 && ny<=m && mat[nx][ny]=='.'){
				nowx=nx,nowy=ny;
				book[nowx][nowy] = 1;
				k--;
			}
			else{
				dir = (dir+1)%4;
				k--;
			}
		}
		int res = 0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				res+=book[i][j];
			}
		}
		cout<<res<<endl;
	}
	return 0;
}
状态
已结束
规则
IOI
题目
4
开始于
2026-8-26 19:00
结束于
2026-8-26 21:00
持续时间
2 小时
主持人
参赛人数
2