Codeforces 7A
来源:互联网 发布:linux 打印内核 编辑:程序博客网 时间:2024/04/30 17:05
一、用O(1)的遍历16条行、列,判断是否全黑做,注意盘面全黑时只需8次而不是16次。
二、BFS(时间复杂度大概介于 O(nlogn)和O(n^2)之间,空间复杂度。。。)
#include "stdio.h"#include "string.h"int main(){ char chessboard[9][9]; int i,j,ans=0,flag; for(i=0;i<=7;i++){scanf("%s",&chessboard[i]); }for(i=0;i<=7;i++){flag=1;for(j=0;j<=7;j++)if(chessboard[i][j]=='W'){flag=0;break;}if(flag)ans++;flag=1;for(j=0;j<=7;j++)if(chessboard[j][i]=='W'){flag=0;break;}if(flag)ans++;}if(ans==16)ans=8;printf("%d",ans);return 0;}
0 0
- Codeforces 7A
- CodeForces 7A
- Codeforces 7A
- CodeForces-a
- Codeforces 903A A
- http://codeforces.com/contest/7/problem/A
- codeforces 7A - Kalevitch and Chess
- Codeforces 7A Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- codeforces 7 A. Kalevitch and Chess
- CodeForces 7A - Kalevitch and Chess
- Educational Codeforces Round 7--A. Infinite Sequence
- Educational Codeforces Round 7 A. Infinite Sequence
- Educational Codeforces Round 7(A)数学
- CodeForces 7A Kalevitch and Chess
- Codeforces 7A Kalevitch and Chess
- 黑马程序员-java-数组
- iOS学习,加速度传感器
- 内存管理
- 编程算法 - 求1+2+...+n(函数指针) 代码(C++)
- QTextStream读写文件
- Codeforces 7A
- 栈的应用——Dijkstra双栈算法表达式求值算法
- 烧开水理论——证明自己存在的三个过程
- 黑马程序员--Java学习257K面试题之银行业务系统
- 黑马程序员-java类-java构造方法-java类数组
- 关键字的秘密
- POJ2395 Out of Hay 最小生成树
- Java课程设计-文档相似性检查系统(完整)测试版
- 海量数据处理算法—Bloom Filter