【题目链接】:http://codeforces.com/contest/508/problem/A

【题意】



让你在一个n*m的方格上给方格染色;

顺序给出染色的k个格子

如果在某一时刻

有一个2*2长方形;

输出是第几个格子;

【题解】



在染色的时候;

判断一下这是4个方格中的哪一个

左上角or右上角or左下角or右下角

然后看看另外3个格子有没有被染色;

有的话就结束;



【Number Of WA】



0



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,0,-1,0,-1,-1,1,1};
const int dy[9] = {0,0,-1,0,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e3+100; int n,m,k;
bool bo[N][N]; int main()
{
//freopen("D:\\rush.txt","r",stdin);
ios::sync_with_stdio(false);
rei(n),rei(m),rei(k);
ms(bo,false);
rep1(i,1,k)
{
int x,y;
rei(x),rei(y);
bo[x][y] = true;
//����
if (bo[x+1][y]&&bo[x+1][y+1]&&bo[x][y+1]) return cout << i<<endl,0;
//����
if (bo[x-1][y]&&bo[x-1][y+1]&&bo[x][y+1]) return cout <<i<<endl,0;
//����
if (bo[x][y-1]&&bo[x-1][y-1]&&bo[x-1][y]) return cout <<i<<endl,0;
//����
if (bo[x][y-1]&&bo[x+1][y-1]&&bo[x+1][y]) return cout <<i<<endl,0;
}
cout << 0 <<endl;
//printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
return 0;
}

【codeforces 508A】Pasha and Pixels的更多相关文章

  1. 【23.33%】【codeforces 557B】Pasha and Tea

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. 【CodeForces 557B】Pasha and Tea

    题 题意 总共有 w 克蛋糕,2n 个盘子,第 i 个盘子容量为 ai ,n 个女孩和 n 个男孩,男孩得到的是女孩得到的蛋糕的两倍,求他们得到蛋糕的最大值. 分析 把盘子从小到大排序,然后 女生得到 ...

  3. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  4. 【74.00%】【codeforces 747A】Display Size

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  6. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  7. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  8. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  9. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

随机推荐

  1. new (C# Reference)

    https://msdn.microsoft.com/en-us/library/51y09td4.aspx In C#, the new keyword can be used as an oper ...

  2. YTU 2732:3798-Abs Problem

    2732: 3798-Abs Problem 时间限制: 1 Sec  内存限制: 128 MB  Special Judge 提交: 167  解决: 60 题目描述 Alice and Bob i ...

  3. astgo-完整功能介绍

    核心功能: Astgo最核心和强大的功能是呼叫中心模块.接入方式:中继卡.模拟卡接入,中继网关.O口网关接入.网络IP接入等.单机200个坐席,通话实时录音.灵活队列分组.开放式IVR设计,修改业务逻 ...

  4. Input 内提示填写内容

    输入框内提示默认内容,用户的点击后提示内容消失,如果填写内容为空,失去焦点后自动显示提示内容 <input type="text" value="搜索" ...

  5. Atlantis(坐标离散化)

    http://poj.org/problem?id=1151 题意:给出矩形的左上角坐标和右下角坐标(坐标的y轴是向下的),求出矩形面积的并.. 今天好困啊..迷迷糊糊的听会神给讲了讲,敲完之后调试了 ...

  6. canvas做的时钟,学习下

    canvas标签只是图形容器,您必须使用脚本来绘制图形. getContext() 方法可返回一个对象,该对象提供了用于在画布上绘图的方法和属性.——获取上下文对象. getContext(" ...

  7. 当下较热web前端技术汇总

    Web前段技术发展很快,主流技术日新月异,想想自己刚毕业那会用的asp技术,现在已经很少有主流网站在使用了.再到后来的J2EE框架,然后SpringMVC大行其道,但是最近各种js框架被广为传播,Ht ...

  8. [Swift通天遁地]七、数据与安全-(9)文件的压缩和解压

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  9. 乐字节-Java8核心特性实战之函数式接口

    什么时候可以使用Lambda?通常Lambda表达式是用在函数式接口上使用的.从Java8开始引入了函数式接口,其说明比较简单:函数式接口(Functional Interface)就是一个有且仅有一 ...

  10. 动态规划DP入门

    百度百科↓ 动态规划(dynamic programming)是运筹学的一个分支,是求解决策过程(decision process)最优化的数学方法.20世纪50年代初美国数学家R.E.Bellman ...