Codeforces Round #288 (Div. 2) A. Pasha and Pixels
来源:互联网 发布:丝绸之路大数据 编辑:程序博客网 时间:2024/06/04 20:04
题意:给定n*m的空白方格,进行k次涂色,将(x,y)处的方格涂成黑色,判断第几次涂色能形成2*2的黑色方格,若不能涂成2*2的方格,输出0。
涂(x,y)时总共就四种情况,四个 if 就能解决,代码太丑。。。。
代码:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <string>#include <map>#include <stack>#include <vector>#include <set>#include <queue>#pragma comment (linker,"/STACK:102400000,102400000")#define maxn 1005#define MAXN 2005#define mod 1000000009#define INF 0x3f3f3f3f#define pi acos(-1.0)#define eps 1e-6#define lson rt<<1,l,mid#define rson rt<<1|1,mid+1,rtypedef long long ll;using namespace std;int mp[maxn][maxn];int n,m,k;bool isok(int x,int y){ if (x>=1&&x<=n&&y>=1&&y<=m&&mp[x][y]) return true; return false;}int main(){ while (~scanf("%d%d%d",&n,&m,&k)) { int x,y; int ans=0; int x1,y1,x2,y2,x3,y3; memset(mp,0,sizeof(mp)); for (int i=1;i<=k;i++) { scanf("%d%d",&x,&y); if (mp[x][y]) continue; x1=x-1,y1=y-1; x2=x-1,y2=y; x3=x,y3=y-1; if (isok(x1,y1)&&isok(x2,y2)&&isok(x3,y3)) { ans=i; break; } x1=x-1,y1=y; x2=x-1,y2=y+1; x3=x,y3=y+1; if (isok(x1,y1)&&isok(x2,y2)&&isok(x3,y3)) { ans=i; break; } x1=x,y1=y-1; x2=x+1,y2=y-1; x3=x+1,y3=y; if (isok(x1,y1)&&isok(x2,y2)&&isok(x3,y3)) { ans=i; break; } x1=x,y1=y+1; x2=x+1,y2=y; x3=x+1,y3=y+1; if (isok(x1,y1)&&isok(x2,y2)&&isok(x3,y3)) { ans=i; break; } mp[x][y]=1; } if (ans<k&&ans) { k=k-ans; while (k--) scanf("%d%d",&x,&y); } printf("%d\n",ans); } return 0;}/*2 3 62 32 21 32 21 21 12 2 41 11 22 12 25 3 72 31 21 14 13 15 33 2*/
3 1
- Codeforces Round #288 (Div. 2) A. Pasha and Pixels
- Codeforces Round #288 (Div. 2) A. Pasha and Pixels
- Codeforces Round #288 (Div. 2) A. Pasha and Pixels
- A. Pasha and Pixels(Codeforces Round #288 (Div. 2))
- A. Pasha and Pixels(Codeforces Round #288 (Div. 2))
- codeforces #508A# Pasha and Pixels
- codeforces 508 A Pasha and Pixels
- CodeForces 508A Pasha and Pixels
- CodeForces 508A Pasha and Pixels
- A. Pasha and Pixels
- A. Pasha and Pixels
- Codeforces Round #337 (Div. 2) A Pasha and Stick B Vika and Squares
- codeforces - 508A - Pasha and Pixels(暴力模拟)
- codeforce A. Pasha and Pixels
- Codeforces Round #337 (Div. 2) A. Pasha and Stick (水)
- Codeforces Round #297 (Div. 2) B. Pasha and String
- Codeforces Round #297 (Div. 2)B Pasha and String
- Codeforces Round #297 (Div. 2) B - Pasha and String
- 资源大全(各行业)
- hdu 递推
- 上机实验3种排序实验8
- linux下查看mysql的安装路径
- poj 1269 判断两直线的关系并求交点
- Codeforces Round #288 (Div. 2) A. Pasha and Pixels
- 2015年第一季度华为网络命令评比大赛
- k神讲故事-金融的结局
- 二叉排序树实验7
- 《人类意念力》正式发布,从精神层面解开大脑的奥秘
- C语言及程序设计初步例程-23 用if语句实现分支结构
- 新手解决SSH项目乱码问题(不用自定义fliter类)
- v$session中server字段何时为none?
- C#缓存