- 扫雷游戏
- 2016-10-04 19:08:19 @
……无奈
测试数据 #0: TimeLimitExceeded, time = 609 ms, mem = 568 KiB, score = 0
测试数据 #1: TimeLimitExceeded, time = 593 ms, mem = 572 KiB, score = 0
测试数据 #2: TimeLimitExceeded, time = 609 ms, mem = 572 KiB, score = 0
测试数据 #3: TimeLimitExceeded, time = 593 ms, mem = 572 KiB, score = 0
测试数据 #4: TimeLimitExceeded, time = 609 ms, mem = 572 KiB, score = 0
测试数据 #5: TimeLimitExceeded, time = 609 ms, mem = 572 KiB, score = 0
测试数据 #6: TimeLimitExceeded, time = 609 ms, mem = 572 KiB, score = 0
测试数据 #7: TimeLimitExceeded, time = 593 ms, mem = 572 KiB, score = 0
测试数据 #8: TimeLimitExceeded, time = 609 ms, mem = 572 KiB, score = 0
测试数据 #9: TimeLimitExceeded, time = 609 ms, mem = 572 KiB, score = 0
#include<iostream>
using namespace std;
int n,m,xx[8]={0,0,-1,1,-1,-1,1,1},yy[8]={1,-1,0,0,1,-1,1,-1};
char c[100][100],ans[100][100];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) cin>>c[i][j];
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(c[i][j]=='*'){
ans[i][j]='*';cout<<'*';continue;
}
int tmp=0;
for(int k=0;k<8;k++){
if(i+xx[k]>0&&i+xx[k]<=n&&j+yy[k]>0&&j+yy[k]<=m)
if(c[i+xx[k]][j+yy[k]]=='*') tmp++;
}
ans[i][j]=tmp+48;
cout<<ans[i][j];
}
cout<<endl;
}
}
2 条评论
-
evian LV 8 @ 2016-10-04 19:58:56
……刚用同样的代码AC了……30ms……我只能说评测机……
-
2016-10-04 19:25:41@
这种题都能被卡T我也是醉了
- 1