poj 1656 Counting Black
来源:互联网 发布:解放军报网络图片赵阳 编辑:程序博客网 时间:2024/04/24 08:48
这个本来应该是不水的,估计题意原来是让用线段树或者树状数组做的,但是,题目里的数据规模太小了,直接模拟就过了。。也就成超级水题了。
#include <stdio.h>#include <string.h>int map[103][103];//在外部定义自动初始化为0int main(){int n;scanf("%d",&n);char input[10];//黑、白、测试int x,y,L;//边界界定值int i,j;int count;//黑色方块的计算器while(n--){scanf("%s",input);scanf("%d%d%d",&x,&y,&L);//printf("输出:%s %d %d %d\n\n",input,x,y,L);// Paint a white square on the board, // the square is defined by left-top grid (x, y)// and right-bottom grid (x+L-1, y+L-1)if(strcmp(input,"BLACK")==0){for(i=x;i<=x+L-1;i++)for(j=y;j<=y+L-1;j++)map[i][j]=1;}if(strcmp(input,"WHITE")==0){for(i=x;i<=x+L-1;i++)for(j=y;j<=y+L-1;j++)map[i][j]=0;}// Ask for the number of black grids // in the square (x, y)- (x+L-1, y+L-1)count=0;if(strcmp(input,"TEST")==0){for(i=x;i<=x+L-1;i++)for(j=y;j<=y+L-1;j++){if(map[i][j]==1)count++;}printf("%d\n",count);}}return 0;}
- POJ 1656 Counting Black
- poj 1656 Counting Black
- POJ 1656 Counting Black
- poj 1656 Counting Black
- poj 1656 Counting Black
- poj 1656 Counting Black
- poj 1656 Counting Black
- poj 1656 Counting Black
- POJ 1656 Counting Black
- Poj 1656 Counting Black
- poj 1656 Counting Black 水题
- POJ-1656-Counting Black- 四分树
- POJ 1656 Counting Black(水~)
- poj-1656-Counting Black-(树状数组)
- POJ-1565-Counting Black
- PKU 1656 Counting black
- 1656:Counting Black
- POJ-1656 Counting Black (二维树状数组 入门题)
- 趁着年轻多干点事吧!!!
- java 对象存储 享元模式
- CERC2012 D - Non-boring sequences 暴力
- BLE芯片CC254x 系统资源(1)
- memcached安装
- poj 1656 Counting Black
- linux启动流程图+mysql协议图
- Apache CXF Spring SOAP MTOM example
- 动态规划入门——Piggy-Bank
- Java对MySQL数据库进行连接、查询和修改
- memcache文章汇总
- 链接推荐整理
- java直接rs.updateRow()来更新数据库
- POJ 2411 Mondriaan's Dream