cf 328 div 2 A. PawnChess

本文深入探讨了游戏开发领域的核心技术,包括游戏引擎、图形渲染、音视频处理等关键环节,为开发者提供全面的技术指导。

http://codeforces.com/contest/592/problem/A

A. PawnChess
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess».

This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and white pawns are placed on the board. The number of black pawns placed is not necessarily equal to the number of white pawns placed.

Lets enumerate rows and columns with integers from 1 to 8. Rows are numbered from top to bottom, while columns are numbered from left to right. Now we denote as (r, c) the cell located at the row r and at the column c.

There are always two players A and B playing the game. Player A plays with white pawns, while player B plays with black ones. The goal of player A is to put any of his pawns to the row 1, while player B tries to put any of his pawns to the row 8. As soon as any of the players completes his goal the game finishes immediately and the succeeded player is declared a winner.

Player A moves first and then they alternate turns. On his move player A must choose exactly one white pawn and move it one step upward and player B (at his turn) must choose exactly one black pawn and move it one step down. Any move is possible only if the targeted cell is empty. It's guaranteed that for any scenario of the game there will always be at least one move available for any of the players.

Moving upward means that the pawn located in (r, c) will go to the cell (r - 1, c), while moving down means the pawn located in (r, c) will go to the cell (r + 1, c). Again, the corresponding cell must be empty, i.e. not occupied by any other pawn of any color.

Given the initial disposition of the board, determine who wins the game if both players play optimally. Note that there will always be a winner due to the restriction that for any game scenario both players will have some moves available.

Input

The input consists of the board description given in eight lines, each line contains eight characters. Character 'B' is used to denote a black pawn, and character 'W' represents a white pawn. Empty cell is marked with '.'.

It's guaranteed that there will not be white pawns on the first row neither black pawns on the last row.

Output

Print 'A' if player A wins the game on the given board, and 'B' if player B will claim the victory. Again, it's guaranteed that there will always be a winner on the given board.

Sample test(s)
input
........
........
.B....B.
....W...
........
..W.....
........
........
output
A
input
..B.....
..W.....
......B.
........
.....W..
......B.
........
........
output
B
题目 大意:

 player  A use W  pawn,player B use B pawn ,B pawn want go  to row 8,and W pawn want  go to  row  1,but if  tow pawn in on column ,and B is high  than W,they can‘t

move ,A  frist move ,every time ,they can only move one cell,who frist get the destination ,who is winer,  ouput winer;;

me  code :::

#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
char map[10][10];
int main()
{
    int w=100,b=-9;
    for(int i=0;i<8;i++)
        cin>>map[i];
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
          if(map[i][j]=='W')
          {
              int flag=0;
              for(int k=i-1;k>=0;k--)
              {
                  if(map[k][j]=='B')
                    flag=1;
              }
              if(flag==0&&i<w)
              {
                  w=i;
              }
          }
        }
    }
    for(int i=7;i>=0;i--)
    {
        for(int j=0;j<8;j++)
        {
            if(map[i][j]=='B')
            {
                int ff=0;
                for(int k=i+1;k<8;k++)
                {
                    if(map[k][j]=='W')
                        ff=1;
                }
                if(ff==0&&i>b)
                    b=i;
            }
        }
    }
    b=8-b-1;
   ///cout<<w<<" "<<b<<endl;
    if(w<=b)
        cout<<"A"<<endl;
    else
        cout<<"B"<<endl;

    return 0;
}


### 关于 Codeforces CF994 Div. 2 的题目与解答 #### 题目概述 Codeforces Round #412 (Div. 2),即 CF994,采用动态评分机制。这种机制意味着一个问题的最大分值取决于解决问题的人数与总参赛人数的比例[^1]。 #### 动态评分机制解释 对于该轮比赛而言,如果某道题目的解决者数量占总参与者的比例较低,则这道题目的分数会相对较高;反之则低。所有至少提交了一次代码的人都被视为参加了这场比赛。 #### 示例解法展示 考虑到不同的算法挑战,在这里提供一道关于字符串处理的问题及其解决方案作为例子: ##### 不同字符计数问题 给定一个长度不超过 \(10^5\) 的字符串,目标是计算其中不同字符的数量并输出重复字符的次数。以下是实现这一功能的一个 C++ 程序片段: ```cpp #include<bits/stdc++.h> using namespace std; const int N=100000+10; char a[N]; int main(){ int n; while(~scanf("%d",&n)){ scanf("%s",a); sort(a,a+n); int x=unique(a,a+n)-a; // 计算不重复字符数目 if(n>26) printf("-1\n"); else printf("%d\n",n-x); // 输出重复字符个数 } return 0; } ``` 此程序通过 `sort` 函数对输入字符串进行了排序,并利用 STL 中的 `unique()` 来去除相邻相同的元素,从而统计出独一无二的字符数量[^2]。 #### 构建三维结构体模型 另一个有趣的案例涉及构建由立方体组成的二维网格表示的物体。每个位置上的整数值代表堆叠在此处的小方块的高度。为了重建这个对象的外观视角下的形态,可以按照如下方法操作: ```cpp #include<bits/stdc++.h> using namespace std; const int N=107; int n,m,h,mp[N][N],a[N],b[N],i,j,k; int main(){ for(scanf("%d%d%d",&n,&m,&h),i=1;i<=m;++i){ scanf("%d",a+i); } for(i=1;i<=n;++i){ scanf("%d",b+i); } for(i=1;i<=n;++i){ for(j=1;j<=m;++j){ scanf("%d",&mp[i][j]); if(mp[i][j]){ mp[i][j]=min(a[j],b[i]); // 取主视图和侧视图高度较小者 } } } for(i=1;i<=n;++i,puts("")){ for(j=1;j<=m;++j){ printf("%d ",mp[i][j]); } } } ``` 这段代码接收了两组数据——分别对应每一列以及每一行的最大可能高度限制,并据此调整实际放置的立方体高度以满足视觉效果的要求[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值