记录编号 |
116550 |
评测结果 |
AAAAAAAAAA |
题目名称 |
神奇的风 |
最终得分 |
100 |
用户昵称 |
HouJikan |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.039 s |
提交时间 |
2014-08-26 08:48:54 |
内存使用 |
0.69 MiB |
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <ctime>
#include <iterator>
#include <functional>
#define pritnf printf
#define scafn scanf
#define For(i,j,k) for(int i=(j);i<=(k);(i)++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint;
const int INF=0x7ffffff;
//==============struct declaration==============
struct winds
{
int row,line,level,rnd;
winds(int row,int line,int level,int rnd):row(row),line(line),level(level),rnd(rnd){} ;
winds()
{
;
}
};
//==============var declaration=================
char maps[210][210];
int level[210][210];
int rnd[210][210];
int mvr[4]={0,1,0,-1};
int mvc[4]={1,0,-1,0};
//==============function declaration============
//==============main code=======================
int main()
{
string FileName="wind";//程序名
string FloderName="COGS";//文件夹名
freopen((FileName+".in").c_str(),"r",stdin);
freopen((FileName+".out").c_str(),"w",stdout);
#ifdef DEBUG
system(("cp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\standard.cpp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\submit.txt").c_str());
#endif
int r,c;
queue <winds> Q;
scanf("%d%d",&r,&c);
cin.ignore(10,10);
winds start,ends;
memset(level,0,sizeof(level));
memset(rnd,0,sizeof(rnd));
For(i,0,r-1)
{
cin.getline(maps[i],250);
For(j,0,c-1)
{
if (maps[i][j]=='S')
{
start.row=i;
start.line=j;
start.level=16384;
level[i][j]=16384;
}
if (maps[i][j]=='E')
{
ends.row=i;
ends.line=j;
}
}
}
scanf("%d",&start.rnd);
rnd[start.row][start.line]=start.rnd;
Q.push(start);
winds x;
while (!Q.empty())
{
x=Q.front();
Q.pop();
For(i,0,3)
{
int rr=x.row+mvr[i];
int cc=x.line+mvc[i];
if (rr>=0&&rr<r&&cc>=0&&cc<c)
{
if (maps[rr][cc]=='.'||maps[rr][cc]=='E')
if (x.level>level[rr][cc])
{
level[rr][cc]=x.level;
rnd[rr][cc]=!rnd[x.row][x.line];
Q.push(winds(rr,cc,x.level,!x.rnd));
}
if (maps[rr][cc]=='*')
if (x.level/2>level[rr][cc])
{
level[rr][cc]=x.level/2;
rnd[rr][cc]=!rnd[x.row][x.line];
Q.push(winds(rr,cc,x.level/2,!x.rnd));
}
}
}
}
if (level[ends.row][ends.line]==0)
printf("There's no wind!\n");
else
printf("%d\n%d\n",level[ends.row][ends.line],rnd[ends.row][ends.line]);
return 0;
}
//================fuction code====================