CDOJ 1221 Ancient Go
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CDOJ 1221 Ancient Go相关的知识,希望对你有一定的参考价值。
#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; }
以上是关于CDOJ 1221 Ancient Go的主要内容,如果未能解决你的问题,请参考以下文章
[Go] 通过 17 个简短代码片段,切底弄懂 channel 基础
解决go: go.mod file not found in current directory or any parent directory; see ‘go help modules‘(代码片段