ural1628 White Streaks
White Streaks
Memory limit: 64 MB
Input
Output
Samples
input | output |
---|---|
3 5 4 |
8 |
5 1 2 |
2 |
分析:模拟,注意周围只有自己一个白格子时算一个;
参照http://www.cnblogs.com/shangyu/archive/2013/10/01/3348500.html;
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <hash_map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=3e4+;
const int dis[][]={,,-,,,-,,};
using namespace std;
using namespace __gnu_cxx;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p%mod;p=p*p%mod;q>>=;}return f;}
int n,m,k,t,now,ans;
vi a[maxn],b[maxn];
int main()
{
int i,j;
scanf("%d%d%d",&n,&m,&k);
rep(i,,k)
{
int x,y;
scanf("%d%d",&x,&y);
a[x].pb(y),b[y].pb(x);
}
rep(i,,n)
{
a[i].pb(m+);
sort(a[i].begin(),a[i].end());
now=;
for(int x:a[i])
{
if(x-now>)ans++;
now=x;
}
}
rep(i,,m)
{
b[i].pb(n+);
sort(b[i].begin(),b[i].end());
now=;
for(int x:b[i])
{
if(x-now>)ans++;
else if(x-now==)
{
int y=x-,pre=;
for(int r:a[y])
{
if(r>i)
{
if(r-pre==)ans++;
break;
}
pre=r;
}
}
now=x;
}
}
printf("%d\n",ans);
//system("Pause");
return ;
}
ural1628 White Streaks的更多相关文章
- 1628. White Streaks(STL)
1628 题意不太好理解 求横黑条 和竖黑条共有多少个 注意1*1的情况 如果横向纵向都是1*1 算为一个 否则不算 用了下vector 枚举找下 #include <iostream> ...
- imshow() displays a white image for a grey image
Matlab expects images of type double to be in the 0..1 range and images that are uint8 in the 0..255 ...
- ural 2063. Black and White
2063. Black and White Time limit: 1.0 secondMemory limit: 64 MB Let’s play a game. You are given a r ...
- 彩色照片转换为黑白照片(Color image converted to black and white picture)
This blog will be talking about the color image converted to black and white picture. The project st ...
- HDU 5113 Black And White 回溯+剪枝
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5113 Black And White Time Limit: 2000/2000 MS (Java/ ...
- SCU3185 Black and white(二分图最大点权独立集)
题目大概说有几个黑色.白色矩阵,问能选出黑白不相交的矩形面积和的最大值. 建二分图,黑色矩阵为X部的点,白色为Y部,XY的点权都为其矩阵面积,如果有个黑白矩阵相交则它们之间有一条边,那样问题就是要从这 ...
- White Rectangles[HDU1510]
White Rectangles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- nVIDIA SDK White Paper ----Vertex Texture Fetch Water
http://blog.csdn.net/soilwork/article/details/713842 nVIDIA SDK White Paper ----Vertex Texture Fetch ...
- Magento white screen or how XML can break your site?
Magento white screen or how XML can break your site? by SANDO on 02. OCT, 2012 in MAGENTO, SMALL TIP ...
随机推荐
- 解析:DNS 原理(入门篇)
DNS 是互联网核心协议之一.不管是上网浏览,还是编程开发,都需要了解一点它的知识. 本文详细介绍DNS的原理,以及如何运用工具软件观察它的运作.我的目标是,读完此文后,你就能完全理解DNS. 一.D ...
- Android Studio一直build、一直refreshing、一直buiding gradle project into的终极解决办法
打开我的电脑,打开C:\Users\用户名, 把红圈的文件夹都删了 如果AndroidStudioProjects文件夹里那些project都不重要,也可以跟红圈文件夹删了, 然后再打开android ...
- 使用composer命令创建laravel项目命令详解
composer命令创建laravel项目的命令是: composer create-project --prefer-dist laravel/laravel blog "5.2.*&qu ...
- shell中 if else以及大于、小于、等于逻辑表达式介绍
比如比较字符串.判断文件是否存在及是否可读等,通常用"[]"来表示条件测试. 注意:这里的空格很重要.要确保方括号的空格.笔者就曾因为空格缺少或位置不对,而浪费好多宝贵的时间. i ...
- asp.net如何删除文件夹及文件内容操作
static void DeleteDirectory(string dir) { && Directory.GetFiles(dir).Length == ) { Directory ...
- xmlHTTP技术资料
一.数据库远程管理技术 基于互联网的广域网现代应用中的一个重要环节是数据库远程监控.首先简单回顾一下互联网上的数据库远程管理技术的发展过程和方式: 早期通过编写CGI-BIN程序模块进行数据库远程管理 ...
- ASP.NET中使用Server.Transfer()方法在页间传值 实例
以下代码在VS2008中测试通过 <%@ Page Language="C#" AutoEventWireup="true" CodeFile=" ...
- nextSibling,previousSibling,childNodes常见错误
在使用nextSibling与previousSibling时,常出现选不到预计对象的情况 eg: <div class="a">1</div> <d ...
- 相对路径json无法获取
在获取json文件内容时,有时会出现相对路径上的json文件无法获取的情况,Chrome上的解决方案如下: 1.右击桌面上的Chrome浏览器图标,点击属性; 2.在目标输入框的内容后头加上--arg ...
- 转 : ANT 调用sqlplus 客户端
Jenkins安装与配置 (版本控制) 1 用ant脚本执行sql语句现在我需要写一个ant脚本来实现项目安装,情况是这样的,客户现在运行的版本可能是2.0,安装目录里可能有REL_1_0,REL_ ...