Alice and Bob(mutiset容器)
Alice and Bob
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4174 Accepted Submission(s): 1310
2
1 2
3 4
2 3
4 5
3
2 3
5 7
6 8
4 1
2 5
3 4
2
题解:
Alice 用自己的牌覆盖Bob的牌,问最多可以覆盖多少张;用mutiset容器,multiset可以存多个同值的点;另外在外边写二分会超时,mutiset里面的二分不会超时。。。
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<set>
#include<algorithm>
using namespace std;
const int MAXN = ;
multiset<int>st;
struct Node{
int x, y;
friend bool operator < (Node a, Node b){
if(a.x != b.x)
return a.x < b.x;
else
return a.y < b.y;
}
void input(){
scanf("%d%d", &this->x, &this->y);
}
};
Node Alice[MAXN], Bob[MAXN];
int main(){
int T, N;
scanf("%d", &T);
while(T--){
scanf("%d", &N);
for(int i = ; i < N; i++){
Alice[i].input();
}
sort(Alice, Alice + N);
for(int i = ; i < N; i++){
Bob[i].input();
}
sort(Bob, Bob + N);
int ans = ;
st.clear();
multiset<int>::iterator iter;
for(int i = , j = ; i < N; i++){
while(j < N && Alice[i].x >= Bob[j].x){
st.insert(Bob[j].y);
j++;
}
if(st.empty())continue;
iter = st.lower_bound(Alice[i].y);
if(iter == st.end() || *iter > Alice[i].y){
iter--;
}
if(Alice[i].y >= *iter)ans++, st.erase(iter);
}
printf("%d\n", ans);
}
return ;
}
Alice and Bob(mutiset容器)的更多相关文章
- hdu 4268 Alice and Bob
Alice and Bob Time Limit : 10000/5000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Tota ...
- 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob
Alice and Bob Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- bzoj4730: Alice和Bob又在玩游戏
Description Alice和Bob在玩游戏.有n个节点,m条边(0<=m<=n-1),构成若干棵有根树,每棵树的根节点是该连通块内编号最 小的点.Alice和Bob轮流操作,每回合 ...
- Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...
- sdutoj 2608 Alice and Bob
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2608 Alice and Bob Time L ...
- 2014 Super Training #6 A Alice and Bob --SG函数
原题: ZOJ 3666 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3666 博弈问题. 题意:给你1~N个位置,N是最 ...
- ACdream 1112 Alice and Bob(素筛+博弈SG函数)
Alice and Bob Time Limit:3000MS Memory Limit:128000KB 64bit IO Format:%lld & %llu Submit ...
- 位运算 2013年山东省赛 F Alice and Bob
题目传送门 /* 题意: 求(a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*.......*(an-1 * x^(2^(n-1))+1) 式子中,x的p次方的系数 二进制位运算:p ...
- SDUT 2608:Alice and Bob
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Alice and Bob like playing ...
随机推荐
- 腾讯TT浏览器应用程序发生异常(0xc0000409) 位置为0x027a1f7f 的解决办法
2013年8月26日下午,腾讯TT浏览器 4.8版1000 出现“应用程序发生异常(0xc0000409) 位置为0x027a1f7f ”的错误,导致浏览器自动关闭. 无论重新卸载安装还是 清理系统 ...
- 【Spark Core】任务运行机制和Task源代码浅析1
引言 上一小节<TaskScheduler源代码与任务提交原理浅析2>介绍了Driver側将Stage进行划分.依据Executor闲置情况分发任务,终于通过DriverActor向exe ...
- HDU 1813 Escape from Tetris (IDA*)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1813 题意:给你一个n*n的迷宫,其中0代表有一个人在这个位置,1代表墙,现在要求一个路线,使所有的人通 ...
- Boost线程库学习笔记
一.创建一个线程 创建线程 boost::thread myThread(threadFun); 需要注意的是:参数可以是函数对象或者函数指针.并且这个函数无参数,并返回void类型. 当一个thre ...
- [Python笔记][第四章Python正则表达式]
2016/1/28学习内容 第四章 Python字符串与正则表达式之正则表达式 正则表达式是字符串处理的有力工具和技术,正则表达式使用预定义的特定模式去匹配一类具有共同特征的字符串,主要用于字符串处理 ...
- jquery返回顶部
// 返回顶部 var fixed_totop = $('.back_top').on('click',function(){ $('html, body').animate({scrollTop: ...
- hbase学习笔记-----REST客户端
1. 启动REST服务 a.启动一个非守护进程模式的REST服务器(ctrl+c 终止) bin/hbase rest start b.启动守护进程模式的REST服务器 bin/hbase-daemo ...
- x^2+y^2=N的整数解?
本文系转载:http://blog.sina.com.cn/s/blog_a661ecd50101cv41.html 我们先研究这个问题的一部分:哪些素数是两平方数之和?为什么我们先研究素数,有个很重 ...
- (原)使用mkl中函数LAPACKE_sgesv计算矩阵的逆矩阵
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5578027.html 参考文档:mkl的说明文档 lapack_int LAPACKE_sgesv(i ...
- ZendFramework2 源码分析 index.php
<?php /** * This makes our life easier when dealing with paths. Everything is relative * to the a ...