本文主要是介绍XTOJ 1173 Five Tiger,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
OJ题目:click here ~~
AC_CODE
int grid[6][6];int dawuhu()
{return grid[1][1]&& grid[1][5]&& grid[5][1]&& grid[5][5]&& grid[3][3];
}int wuhu()
{int ret = 0;for(int i = 1;i <= 3;i++)for(int j = 1;j <= 3;j++){ret += grid[i][j] && grid[i][j+2] && grid[i+1][j+1] && grid[i+2][j] && grid[i+2][j+2] ;}return ret;
}int tongtian()
{int ret = 0;for(int i = 1;i <= 5;i++)//横着{ret += grid[i][1] && grid[i][2] && grid[i][3] && grid[i][4] && grid[i][5];}for(int i = 1;i <= 5;i++){ret += grid[1][i] && grid[2][i] && grid[3][i] && grid[4][i] && grid[5][i];}ret += grid[1][1] && grid[2][2] && grid[3][3] && grid[4][4] && grid[5][5];ret += grid[1][5] && grid[2][4] && grid[3][3] && grid[4][2] && grid[5][1];return ret;
}int sixie()
{int ret = 0;ret += grid[1][4] && grid[2][3] && grid[3][2] && grid[4][1];ret += grid[2][1] && grid[3][2] && grid[4][3] && grid[5][4];ret += grid[2][5] && grid[3][4] && grid[4][3] && grid[5][2];ret += grid[1][2] && grid[2][3] && grid[3][4] && grid[4][5];return ret;
}int sanxie()
{int ret = 0;ret += grid[1][3] && grid[2][2] && grid[3][1];ret += grid[3][1] && grid[4][2] && grid[5][3];ret += grid[3][5] && grid[4][4] && grid[5][3];ret += grid[1][3] && grid[2][4] && grid[3][5];return ret;
}int xiaodou()
{int ret = 0;for(int i = 1;i <= 4;i++){for(int j = 1;j <= 4;j++)ret += grid[i][j] && grid[i][j + 1] && grid[i+1][j] && grid[i+1][j+1];}return ret;
}
int main()
{//freopen("in.txt","r",stdin);int t;cin >> t;while(t--){string s;memset(grid , 0 , sizeof(grid));for(int i = 1;i <= 5;i++){cin >> s;for(int j = 1;j <= 5;j++){if(s[j - 1] == 'x')grid[i][j] = 1;}}int ans = 0;ans += 10*dawuhu();ans += 5*wuhu();ans += 5*tongtian();ans += 4*sixie();ans += 3*sanxie();ans += xiaodou();printf("%d ",ans);for(int i = 1;i <= 5;i++)for(int j = 1;j <= 5;j++)grid[i][j] = 1 - grid[i][j];ans = 0;ans += 10*dawuhu();ans += 5*wuhu();ans += 5*tongtian();ans += 4*sixie();ans += 3*sanxie();ans += xiaodou();printf("%d\n",ans);}return 0;
}
这篇关于XTOJ 1173 Five Tiger的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!