📄 2251.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 2251 on 2006-05-29 at 10:22:42 */
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 128;
const int DIR[][2] = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 }, { 1, 1 }, { 1, -1 },
{ -1, 1 }, { -1, -1 } };
const double SM = 10000;
const double eps = 1e-4;
const double RATE = 1.5;
int w, h;
char map[N][N];
double m[N][N];
bool legal(int x, int y) { return x >= 0 && x < h && y >= 0 && y < w && map[x][y] == 's'; }
int main()
{
int i, j, k, t, T;
scanf("%d", &T);
for(t = 0; t < T; t++) {
scanf("%d %d\n", &h, &w);
double pm = 0, tm = 0;
for(i = 0; i < h; i++) {
gets(map[i]);
for(j = 0; j < w; j++)
if(map[i][j] == 'b') m[i][j] = 0;
else { m[i][j] = SM; pm += SM; }
}
for(i = 0; i < h; i++)
for(j = 0; j < w; j++)
if(map[i][j] != 'c') continue;
else {
for(k = 0; k < 8; k++) {
int x = i+DIR[k][0], y = j+DIR[k][1];
if(legal(x, y)) m[x][y] *= RATE;
}
}
for(i = 0; i < h; i++)
for(j = 0; j < w; j++)
if(map[i][j] == 's') tm += m[i][j];
if(fabs(tm-pm) < eps) printf("Draw %.4lf\n", tm);
else if(tm > pm) printf("Win %.4lf\n", tm-pm);
else printf("Lose %.4lf\n", pm-tm);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -