/ CYOJ /

记录详情

Accepted


  
[Hydro](https://hydro.ac)提供评测服务
# 状态 耗时 内存占用
#1 Accepted 1ms 256.0 KiB
#2 Accepted 2ms 384.0 KiB
#3 Accepted 1ms 256.0 KiB

代码

#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int visited[10][10],n,m,yd[4][2] = {{-1,0},{0,-1},{1,0},{0,1}},sx1,sy1,sx2,sy2,mmx,mmn;
char a[10][10];
queue<int>x,y,mxmn;

int main() {
	cin>>m>>n;
	for(int i = 1; i <= n; i++) {
		scanf("%s",a[i] + 1);
	}
	cin>>sx1>>sy1>>sx2>>sy2;
	if(sx1 <= 0 || sy1 <= 0 || sx2 <= 0 || sy2 <= 0) return 0;
	x.push(sx1),y.push(sy1),mxmn.push(2);
	x.push(sx2),y.push(sy2),mxmn.push(1);
	visited[sx1][sy1] = 2;
	visited[sx2][sy2] = 1;
	while(!(x.empty() && y.empty() && mxmn.empty())) {
		int nx = x.front(),ny = y.front(),nm = mxmn.front();
		x.pop(),y.pop(),mxmn.pop();
		for(int i = 0; i < 4; i++) {
			int tx = nx + yd[i][0],ty = ny + yd[i][1];
			if(tx > 0 && ty > 0 && tx <= n && ty <= m) {
				if(visited[tx][ty] == 0 && a[tx][ty] == '.') {
					visited[tx][ty] = nm;
					x.push(tx),y.push(ty),mxmn.push(nm);
					if(nm == 2) mmx++;
					else if(nm == 1) mmn++;
				}
			}
		}
	}
	if(mmx == mmn) cout<<"draw"<<endl;
	else if(mmx > mmn) cout<<"max"<<endl;
	else if(mmx < mmn) cout<<"min"<<endl;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(a[i][j] == '#') {
				cout<<"#";
			}
			else cout<<visited[i][j];
		}
		cout<<endl;
	}
}

信息

递交者
类型
递交
题目
P1008 棋盘对峙
语言
C++
递交时间
2022-08-29 17:12:36
评测时间
2022-09-04 22:19:36
评测机
分数
100
总耗时
5ms
峰值内存
384.0 KiB