Codeforces Round #157 (Div. 2) A. Little Elephant and Chess

本文解析了Codeforces上一道关于棋盘的操作题,通过分析行操作后的棋盘是否能形成标准黑白相间的棋盘模式。利用C++编程实现判断逻辑,确保每行元素黑白交替,避免相同颜色相邻。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目:http://codeforces.com/contest/259/problem/A

判断一个棋盘经过行操作后能否成为一个正常的黑白相间的棋盘

思路:因为不涉及列操作 只要每行都是黑白相间就可以满足条件

#include <iostream>
#include <cstdlib>
using namespace std;

int a,b,n;
int main()
{
    bool ans=true;
    char start,previous,current;
    for(int i=0;i<8;i++)
    {
        cin >> current;
        start=previous=current;
        for(int j=0;j<6;j++)
        {
            cin>>current;
            if(current==previous)ans=0;
            previous=current;
        }
        cin>>current;
        if(current==previous||current==start) ans=0;
    }

    if(ans) cout << "YES"<<endl;
    else cout << "NO" <<endl;
return 0;
}

 

转载于:https://www.cnblogs.com/danielqiu/archive/2013/01/16/2863127.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值