日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

北邮OJ 1022. 16校赛-Saber's Board

發布時間:2024/9/30 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 北邮OJ 1022. 16校赛-Saber's Board 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

時間限制?5000 ms?內存限制?65536 KB

題目描述

?? ?In a parallel universe, Saber has won the champion of every kind of board games. She even defeated the AI program BetaGo recently! After all the victory she has got, Saber found life so boring that she decided to develop her own kind of board game. The new game named "Diamond Wars" involves two players to play on a randomly generated?N?M?board, each grid is filled with red or blue, indicating the first and the second players. The players then decide?an integer?K?by random. Next, each player take turns to fill a part of the board following the rules: one must choose a grid?(x,y)?in?his color,?KxN?K+1?and?KyM?K+1, and if for all the grids?(i,j)? ? ? that satisfy?i?x+j?yK?1? ? ? ? ? ? ? ? ?, they are all of the player's color, he will color them to green and get 1 score. We?call this?(x,y)?a valid grid. If one player chose an invalid?(x,y), that grid as well as all grids?(i,j)? ? ? ?satisfing the formula will become the opponent's color! The first one who is unable to move when there are still non-green grids on the board, or the one with less score at last will lose the game. As an expert in board games, Saber wants to know exactly how many valid grids the first player can choose at the very beginning. She is confident that she will win every game even being the second player to move.?

輸入格式

?? ?The input starts with an integer?T?(1T20), ? ? ?indicating the number of test cases.?
?? ?For each test case, the first line contains three integers?N,M,K?(1N,M100,12?Kmin(N+1,M+1)). The following?N?lines contain the board, each line with exactly?M?characters. We assume red be 'O' and blue be 'X' to simplify the problem.

輸出格式

?? ?For each test case, print a line containing the answer to the problem Saber is interested in.


【本文出自http://blog.csdn.net/u012662688/article/details/51163528,轉載請注明】

輸入樣例

1 4 5 2 XOOOO OOOOX OOOOO OXXOO

輸出樣例

3 一個好好想一想,大家都能過的題,先枚舉出所有符合條件的x、y,再枚舉出所有符合條件的i、j即可。4重for循環。

#include<cstdio> #include<cmath> #include<algorithm> #define N 150 using namespace std; int main(){int t,n,i,m,k;char str[N][N];for(scanf("%d",&t);t--;){scanf("%d%d%d",&n,&m,&k);for(i=1;i<=n;i++)scanf("%s",str[i]+1);int x,y;int ans=0;int sig;int px,py;for(x=k;x<=n-k+1;x++){for(y=k;y<=m-k+1;y++){sig=1;if(str[x][y]=='O'){for(px=1;px<=n&&sig;px++){for(py=1;py<=m&&sig;py++){if(abs(px-x)+abs(py-y)<=k-1){if(str[px][py]!='O')sig=0;}}}if(sig){ans++;}}}}printf("%d\n",ans);}return 0; }







總結

以上是生活随笔為你收集整理的北邮OJ 1022. 16校赛-Saber's Board的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。