【codeforces 508A】Pasha and Pixels
【题目链接】: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的更多相关文章
- 【23.33%】【codeforces 557B】Pasha and Tea
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【CodeForces 557B】Pasha and Tea
题 题意 总共有 w 克蛋糕,2n 个盘子,第 i 个盘子容量为 ai ,n 个女孩和 n 个男孩,男孩得到的是女孩得到的蛋糕的两倍,求他们得到蛋糕的最大值. 分析 把盘子从小到大排序,然后 女生得到 ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【74.00%】【codeforces 747A】Display Size
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
随机推荐
- sql server的版本检查
https://support.microsoft.com/en-ph/help/321185/how-to-determine-the-version-edition-and-update-leve ...
- [BZOJ 1660] Bad Hair Day
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1660 [算法] Sprease Table + 二分 时间复杂度 : O(NlogN ...
- 【POJ 2965】 The Pilots Brothers' refrigerator
[题目链接] http://poj.org/problem?id=2965 [算法] 位运算 [代码] #include <algorithm> #include <bitset&g ...
- hadoop hbase 快速启动 关闭 配置:
vim ~/.bashrcexport JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 //JDK安装路径export HADOOP_HOME=/usr/l ...
- Hyper-v 3.0 安装centos6.3
Hyper-v 3.0 安装centos6.3 我们说到hyper-v3.0就想到了windows8.windows2012:我们也知道在windows8.windows2012上安装centos系统 ...
- IOException 简单解决方法
java.lang.IllegalStateException异常解决方法 这个异常大多数是由文件读取,下载时抛出,但是偶尔也会由类型转换时异常抛出此异常. 错误:Optional int param ...
- PCB 脱离IIS的Web应用
在用.net Web编程中,我们写好的Web应用首选会挂在IIS上面,因为它足稳定并且功能齐全,但这不是我们唯一的选择,微软给我们提供了Owin组件,Web应该的宿主可以不再是IIS了,有了Owin后 ...
- npm 与 package.json 快速入门教程
npm 与 package.json 快速入门教程 2017年08月02日 19:16:20 阅读数:33887 npm 是前端开发广泛使用的包管理工具,之前使用 Weex 时看了阮一峰前辈的文章了解 ...
- php使用163邮箱发送邮件
email.class.php文件 <? class smtp { /* Public Variables */ var $smtp_port; var $time_out; var $host ...
- codevs地鼠游戏(贪心)
1052 地鼠游戏 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 王钢是一名学习成绩优异的学生,在平时的学习中,他 ...