您好,登錄后才能下訂單哦!
#include<bits/stdc++.h>using namespace std;bool ok;char maze[15][15];char Map[12][12];bool vis[15][15];int x[4] = {0,0,1,-1};int y[4] = {1,-1,0,0};struct ST { int ii; int jj; }; queue<ST> que;void BFS(int cur_i, int cur_j) { int dot = 0; while(!que.empty()) que.pop(); ST now; now.ii = cur_i; now.jj = cur_j; que.push(now); while(!que.empty()) { now = que.front(); que.pop(); vis[now.ii][now.jj] = 1; for(int i=0;i<4;i++) { int tempX = now.ii + x[i]; int tempY = now.jj + y[i]; ST Next; Next.ii = tempX; Next.jj = tempY; if(tempX >=0 && tempX <= 10 && tempY >=0 && tempY <= 10 && !vis[tempX][tempY]) { if(Map[tempX][tempY]=='.') { dot++; vis[tempX][tempY] = 1; } else if(Map[tempX][tempY]=='o') { que.push(Next); vis[tempX][tempY] = 1; } } } } if(dot == 1) { ok = 1; } return ; }int main() { int t; cin>>t; int kase = 1; while(t--) { ok = 0; for(int i=0;i<=8;i++) cin>>maze[i]; for(int i=0;i<=10;i++) { for(int j=0;j<=10;j++) { if(i==0||j==0||i==10||j==10) Map[i][j] = 'x'; else Map[i][j] = maze[i-1][j-1]; } } memset(vis, 0, sizeof(vis)); for(int i=1;i<=9;i++) { for(int j=1;j<=9;j++) { if(Map[i][j]=='o'&&!vis[i][j]) BFS(i, j); for(int ii=1;ii<=9;ii++) for(int jj=1;jj<=9;jj++) if(Map[ii][jj] == '.') vis[ii][jj] = 0; if(ok) goto here; } } here:; if(ok) printf("Case #%d: Can kill in one move!!!\n", kase++); else printf("Case #%d: Can not kill in one move!!!\n", kase++); // cout<<endl; } return 0; }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。