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 ...
随机推荐
- 一步一步学数据结构之n--n(Prim算法)
在这里说下最小连通网的Prim算法: 而Kruskal算法,http://blog.csdn.net/nethanhan/article/details/10050735有介绍,大家可以去看下! Pr ...
- R6010 -abort() has been called错误分析及其解决方法
近期使用vs2010编程出现下面问题.在网上收集了大家的意见之后,整理了一下 导致出现这种原因有: 1.非法指针訪问和内存泄漏 2.大家再查查吧.一定是指针出现故障了.设置的指针范围跟你执行的不正确 ...
- Eclipse中使用正则屏蔽Logcat中的某些Tag
在使用Eclipse进行Android真机调试的时候经常会出现满屏幕的LogCat,即使设定了根据程序分类也不行 经常会有 Dalvikvm InputMethod这样的Tag出现 给自己的应用设定T ...
- Filter简单介绍
一.简单介绍 Filter也称为过滤器,WEB开发者通过Filter技术.对webserver管理的全部web资源:比如Jsp, Servlet, 静态图片文件或静态 html 文件等进行拦截.从而实 ...
- [汇编学习笔记][第五章[BX]和loop指令]
第五章[BX]和loop指令 前言 定义描述性符号“()”来表示一个寄存器或一个内存单元的内容,比如: (ax)表示ax中的内容,(al)表示al的内容. 约定符号ideta表示常量. 5.1 [BX ...
- java编程中的Java.Lang.Math类
1. Math.PI :表示的是圆周率常量: 2.Math.E :表示的是普通常量(e): 3.abs()方法: 表示取绝对值 eg1: int x = Math.abs(50L); ...
- 禁止 favicon.ico 请求
favicon.ico 图标用于收藏夹图标和浏览器标签上的显示,如果不设置,浏览器会请求网站根目录的这个图标,如果网站根目录也没有这图标会产生 404.出于优化的考虑,要么就有这个图标,要么就禁止产生 ...
- javascript切换效果
html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta ...
- Nohttp请求图片的两种简答的方式:普通请求以及缓存请求
开局声明:这是基于nohttp1.0.4-include-source.jar版本写的教程 由于nohttp功能强悍,因此需要多种权限,仅仅一个联网的权限是不够的,如果只给了Internet的权限,去 ...
- VS 2003 无法打开Web项目 文件路径与URL不符 这两者需要映射到相同的服务器位置
解决方法: 将C:\Documents and Settings\Administrator\VSWebCache下面的文件全部删除