【题目链接】: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. git分支的合并和冲突解决【转】

    本文转载自:http://blog.csdn.net/Kingson_Wu/article/details/39227611 http://gitbook.liuhui998.com/3_3.html ...

  2. 常用进制的转换、进制数的and与or或xor异或运算

    [十进制转换成其他进制]例:将25转换为二进制数 解: 25÷2=12 余数1  12÷2=6   余数0  6÷2=3     余数0  3÷2=1     余数1  1÷2=0     余数1 所 ...

  3. Decode the Strings

    http://acm.hdu.edu.cn/showproblem.php?pid=2371 题意:给出一个长度为n的字符串(标号为1~n),以及n个数代表字符串的变换规则,问该字符串是由哪个字符串按 ...

  4. Python多线程、多进程

    1.from  multiprocessing import Process ;  from  threading import Thread 2.进程之间的数据传输 ,一般会使用到pipes, qu ...

  5. ACM_Repeating Characters

    Repeating Characters Time Limit: 2000/1000ms (Java/Others) Problem Description: For this problem, yo ...

  6. 上传Android代码到gerrit服务器

    1. 配置default.xml default.xml是跟Android代码配套的,可参考google Android源码下的default.xml(.repo/manifests/default. ...

  7. [转]Android的userlogin登录

    本文转自:http://hteqc6o.blog.sohu.com/199334086.html 用户注册 1.首先,先画你想要编译出的界面 根据草图,仅仅使用linearLayout的布局是不够的, ...

  8. js的toFixed解惑

    js中的toFixed,C#中的Math.round都是按照银行家算法的定义来算的,这里只拿js作参考,各个浏览器的计算方式并不一样,先看一张图,对比参数很容易就发现了其中的不同之处: 前三个Chro ...

  9. checkbox与文字混排无法对齐到一行的解决办法

    直接上代码: <span><input style="vertical-align:middle" type="checkbox" name= ...

  10. 关闭掉eclipse启动的自动更新功能(提高打开eclipse的速度)