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 ...
随机推荐
- 分析linux下的编译环境
不论是windows下的程序,还是linux下的程序,开发环境都离不开三个目录:include.lib.bin,分别是头文件目录.库文件目录.运行文件目录.或许目录不叫这个名字,但却必不可少,除非你的 ...
- PHP冒泡排序,选择排序,插入排序
1 冒泡排序是两个元素相互比较,找到最小值,然后冒泡到最后,代码如下:
- VS2008 由于应用程序配置不正确,应用程序未能启动。重新安装应用程序可能会纠正这个问题。
提示这个错误,自己的程序是在VS2008下编译的C/C++ win32程序,自己当时在win7上开发测试,都没有问题,正常使用,也在另一台xp系统上也试了,都没有问题.就发给客户了,没想到有些客户竟然 ...
- OpenGL——点的绘制(使用OpenGL来绘制可旋转坐标系的螺旋线)
package com.example.opengl1; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio. ...
- 多线程 AfxBeginThread 与 CreateThread 的区别
简言之: AfxBeginThread是MFC的全局函数,是对CreateThread的封装. CreateThread是Win32 API函数,前者最终要调到后者. 1>.具体说来,Cr ...
- windows-JDK环境变量设置
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_43;CLASS_PATH=.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar;p ...
- TreeView中右击直接获取节点的方法
在TreeView中无法直接右击得到一个节点,因为当你选中其中一个右击时(不能是第一个)他会默认跳到第一个. 有时我们要想直接右击得到选中的节点,又时我们又想选中直接右击跳出一个快捷菜单怎么办了! 在 ...
- ListHelper
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data; ...
- Android开发实现透明通知栏
这个特性是andorid4.4支持的,最少要api19才可以使用,也就是说如果Android的机子是低于4.4,沉浸通知栏是没有效果的.下面介绍一下使用的方法,非常得简单. public void i ...
- I - u Calculate e
Description A simple mathematical formula for e is where n is allowed to go to infinity. This can ac ...