1628. White Streaks(STL)
题意不太好理解 求横黑条 和竖黑条共有多少个 注意1*1的情况 如果横向纵向都是1*1 算为一个 否则不算
用了下vector 枚举找下
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
#define N 30010
vector<int>p[N];
vector<int>q[N];
int o1[N],o2[N];
int main()
{
int i,j,m,n,k,x,y,t,sum=;
scanf("%d%d%d",&m,&n,&k);
for(i = ; i <= k ;i++)
{
scanf("%d%d",&x,&y);
p[x].push_back(y);
q[y].push_back(x);
}
for(i = ; i <= m ; i++)
p[i].push_back(n+);
for(i = ; i <= n ; i++)
q[i].push_back(m+);
for(i = ; i <= m ; i++)
{
t = ;
sort(p[i].begin(),p[i].end());
for(j = ; j < (int)p[i].size() ; j++)
{
if(p[i][j]-t>)
sum+=;
t = p[i][j];
}
}
for(i = ; i <= n ; i++)
{
sort(q[i].begin(),q[i].end());
t = ;
for(j = ; j < (int)q[i].size() ; j++)
{
if(q[i][j]-t>)
sum+=;
else if(q[i][j]-t>)
{
int ot = q[i][j]-;
t = ;
for(int g = ; g < (int)p[ot].size() ; g++)
{
if(p[ot][g]>i)
{
if(p[ot][g]-t<=)
sum+=;
break;
}
t = p[ot][g];
}
}
t = q[i][j];
}
}
printf("%d\n",sum);
return ;
}
1628. White Streaks(STL)的更多相关文章
- ural1628 White Streaks
White Streaks Time limit: 1.0 secondMemory limit: 64 MB The life of every unlucky person has not onl ...
- stl文件格式
http://wenku.baidu.com/view/a3ab7a26ee06eff9aef8077b.html [每个三角形面片的定义包括三角形各个定点的三维坐标及三角形面片的法矢量[三角形的法线 ...
- 【暴力,STL,水】UVa 1523 - Helicopter
Since ancient time, people have been dreaming of flying in the sky. Eventually, the dream was realiz ...
- Codeforces 260D - Black and White Tree
260D - Black and White Tree 思路:把两种颜色先按值sort一下,最小值肯定是叶子,然后把这个叶子和另外一中颜色的一个最小值的节点连接起来,再把这个节点变成叶子,把值减掉就可 ...
- D - Association for Control Over Minds Kattis - control (并查集+STL)
You are the boss of ACM (Association for Control over Minds), an upstanding company with a single go ...
- 详细解说 STL 排序(Sort)
0 前言: STL,为什么你必须掌握 对于程序员来说,数据结构是必修的一门课.从查找到排序,从链表到二叉树,几乎所有的算法和原理都需要理解,理解不了也要死记硬背下来.幸运的是这些理论都已经比较成熟,算 ...
- STL标准模板库(简介)
标准模板库(STL,Standard Template Library)是C++标准库的重要组成部分,包含了诸多在计算机科学领域里所常见的基本数据结构和基本算法,为广大C++程序员提供了一个可扩展的应 ...
- STL的std::find和std::find_if
std::find是用来查找容器元素算法,但是它只能查找容器元素为基本数据类型,如果想要查找类类型,应该使用find_if. 小例子: #include "stdafx.h" #i ...
- STL: unordered_map 自定义键值使用
使用Windows下 RECT 类型做unordered_map 键值 1. Hash 函数 计算自定义类型的hash值. struct hash_RECT { size_t operator()(c ...
随机推荐
- Android核心组件 Service
Service: 服务 Service 是Activity系统的核心组件之一. 因此需要继承和注册 Service 是内有界面的, 适合在后台长期的执行任务. (如放歌, 检测版本跟新, 下载, 上传 ...
- ListView练习
1. 在 .xml中创建一个ListView是不会显示出来的. 2. ListView的Item: 列表项, 3. 显示ListView的4个要素: 3.1 ListView控件:在layout布局中 ...
- php 批量生成html,txt文件的方法(实例代码)
php批量生成html,txt文件的实现代码. 首先,建立一个conn.php 链接数据库. <?php $link = mysql_connect("mysql_host" ...
- Mindjet.MindManager“参数错误”解决办法,适用于9.0、10.0和14.0
MindManager出14.0版本了,但是在应用个别模板的时候会提示“参数错误”,然后自动关闭. 解决办法: 如果是win7系统,可以进入C:\Users\(用户名) \AppData\Loca ...
- LeetCode 解题报告--202Happy Number
1 题目描述 Write an algorithm to determine if a number is "happy". A happy number is a number ...
- Python学习_数据排序方法
Python对数据排序又两种方法: 1. 原地排序:采用sort()方法,按照指定的顺序排列数据后用排序后的数据替换原来的数据(原来的顺序丢失),如: >>> data1=[4,2, ...
- Android笔记——Bitmap自动取色(纯搬运)
2015/6/12更新:发现一个更好的,带demo https://github.com/MichaelEvans/ColorArt 说明: 这个是一个老外写的自动自动从bitmap中取主色与第二主色 ...
- PostgreSQL+PostGIS的使用 函数清单
一. PostgreSQL与PostGIS的关系 PostgreSQL 是世界上技术最先进的开源数据库,其前身是1977年一个源于Berkeley名为Ingres的非关系型数据库,其项目领导人为Mic ...
- HelloWorld和数据绑定
HelloWorld和数据绑定 目录导读: AngularJS 系列 学习笔记 目录篇 前言: 好记性不如烂键盘,随笔就是随手笔记,希望以后有用. 本篇目录: 1. Hello World 2. An ...
- javascript高级编程笔记04(基本概念)
Function类型 Es5中规范了另一个函数对象的属性:caller,这个属性中保存着调用当前函数的函数的引用,如果是在全局作用域中调用当前函数,这它的值为null function outer() ...