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 ...
随机推荐
- ubuntu server版连接vpn服务器
命令行的方法: 1.要下载pptp的客户端 sudo apt-get install pptp-linux 2.创建连接 sudo pptpsetup –create vpn001 –s ...
- WebForm页面运行周期--页面关系
1.前台文件类继承于后台文件类 2.当前台文件中包含某个标签runat= server的时候,asp.net就会在编译这个页面前后台文件类的时候,在后台类中添加一个相应的控件对象:当页面被访问,也就是 ...
- Oracle Lock 概述
按锁的机制分类 排他锁( X ):如果事务T对对象A加上排他锁,则只允许T对A对象读取和修改,其他事务不能对A增加任何锁,直到T释放加载A上的排他锁 共享锁( S ):如果事务T对表A加上共享锁,则事 ...
- Perl中的正则表达
前几天用到了Perl语言,主要看了一下Perl中的正则表达式,在各种网页语言中,正则表达式在处理字符串的时候十分有用,所以这里就简单说一下在Perl中正则表达式的应用. 先上代码 #!/usr/bin ...
- compared woth QPSK, what is the advantages of QAM(16QAM or 64QAM?)
1.QPSK QPSK是英文Quadrature Phase Shift Keying的缩略语简称,意为正交相移键控,是一种数字调制方式.在数字信号的调制方式中QPSK四相移键控是目前最常用的一种卫星 ...
- 【IOS】利用ASIHTTPRequest 实现一个简单的登陆验证
http://blog.csdn.net/toss156/article/details/7638529
- div蒙版+可移动
<html> <head> <title></title> <script src="jquery-1.8.2.js&q ...
- HTML网页中添加音频视频动画...(转)
在网页中适当嵌入音频和视频能够充分显示网页的多媒体特性,特别是随着宽带网的普及,使得网络广播和网络视频成为现实,网页音频和视频的重要性也日益突显.具体来说,网页音频和视频的嵌入方法主要有三种: 一.b ...
- this.Invoke和this.BeginInvoke的区别
private void button1_Click(object sender, EventArgs e) { "; this.Invoke(new EventHandler(delega ...
- springside springmvc 的一个SB问题
<form id="inputForm" modelAttribute="order" action="${ctx}/myorder/orde ...