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

刺骨的言语ヽ痛彻心扉 2021-12-24 08:57 289阅读 0赞

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

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

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

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int a,b,n;
  5. int main()
  6. {
  7. bool ans=true;
  8. char start,previous,current;
  9. for(int i=0;i<8;i++)
  10. {
  11. cin >> current;
  12. start=previous=current;
  13. for(int j=0;j<6;j++)
  14. {
  15. cin>>current;
  16. if(current==previous)ans=0;
  17. previous=current;
  18. }
  19. cin>>current;
  20. if(current==previous||current==start) ans=0;
  21. }
  22. if(ans) cout << "YES"<<endl;
  23. else cout << "NO" <<endl;
  24. return 0;
  25. }

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

发表评论

表情:
评论列表 (有 0 条评论,289人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Codeforces Round #556 (Div. 2) A

    题面很简单,思路就是简单贪心,si数组是贮存购买数组,bi数组是贮存出售数组,题面是给你r的货币,让你通过出售和购买来获取最大价值,第一种算法是通过找出bi数组最大值,和si数