2015 Benelux Algorithm Programming Contest E-Excellent Engineers
题目大意:有n个人,每个人都有三个物品,排名分别为a[ i ],b[ i ],b[ i ],现在要删掉其中的一些人
如果一个人x的三个物品的排名为a[ x ],b[ x ],b[ x ],若存在另一个人y物品排名为a[ y ],b[ y ],b[ y ],
且a[ y ]<a[ x ] && b[ y ]<b[ x ] && c[ y ]<c[ x ],则删掉x,问你最后剩下多少人。
思路:一开始肯定要按一个物品的排名进行排序,然后就三个人想了半小时没想出来,感觉要用数据
结构,但是不知道怎么写,看来还是对线段树不太了解!!!!
首先,我们按物品a的排名排序,然后我们用b物品的排名建立线段树维护物品c的最小值即可。
#include<bits/stdc++.h>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const int N=1e5+;
const int inf=0x3f3f3f3f;
int mn[N<<],n;
struct node
{
int a,b,c;
bool operator <(const node &t)const
{
return a<t.a;
}
}w[N];
void updata(int x,int v,int l,int r,int rt)
{
if(l==r)
{
mn[rt]=min(mn[rt],v);
return;
}
int m=(l+r)>>;
if(x<=m) updata(x,v,lson);
else updata(x,v,rson);
mn[rt]=min(mn[rt<<],mn[rt<<|]);
}
int query(int L,int R,int l,int r,int rt)
{
if(l>=L && r<=R) return mn[rt];
int m=(l+r)>>;
int ans=inf;
if(L<=m) ans=min(ans,query(L,R,lson));
if(R>m) ans=min(ans,query(L,R,rson));
return ans;
}
int main()
{
int T; cin>>T;
while(T--)
{
cin>>n;
for(int i=;i<n;i++) scanf("%d%d%d",&w[i].a,&w[i].b,&w[i].c);
sort(w,w+n);
memset(mn,inf,sizeof(mn));
int ans=;
for(int i=;i<n;i++)
{
int g=query(,w[i].b,,n,);
if(g>w[i].c) ans++;
updata(w[i].b,w[i].c,,n,);
}
printf("%d\n",ans);
}
return ;
}
2015 Benelux Algorithm Programming Contest E-Excellent Engineers的更多相关文章
- 2015 Benelux Algorithm Programming Contest (BAPC 15)E - Excellent Engineers
这题想了很久没思路,不知道怎么不sort维护二维的最小值 emmmm原来是线段树/树状数组,一维sort,二维当成下标,维护三维的最小值 #include<bits/stdc++.h> # ...
- 2015 Benelux Algorithm Programming Contest I- Interesting Integers
题目大意:给你一个数字n(n<=1e9) ,让你求一个能包含这个数的斐波那契数列的第一项a 和第二项b,找出b最小的那个. 帮我复习了一下扩展欧几里得.... 思路:a,b,a+b,a+2b…… ...
- 计蒜客 28315.Excellent Engineers-线段树(单点更新、区间最值) (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 E)
先写这几道题,比赛的时候有事就只签了个到. 题目传送门 E. Excellent Engineers 传送门 这个题的意思就是如果一个人的r1,r2,r3中的某一个比已存在的人中的小,就把这个人添加到 ...
- 2014 Benelux Algorithm Programming Contest (BAPC 14)E
题目链接:https://vjudge.net/contest/187496#problem/E E Excellent Engineers You are working for an agency ...
- Benelux Algorithm Programming Contest 2014 Final(第二场)
B:Button Bashing You recently acquired a new microwave, and noticed that it provides a large number ...
- 2020.3.14--训练联盟周赛 Preliminaries for Benelux Algorithm Programming Contest 2019
1.A题 题意:给定第一行的值表示m列的最大值,第m行的值表示n行的最大值,问是否会行列冲突 思路:挺简单的,不过我在一开始理解题意上用了些时间,按我的理解是输入两组数组,找出每组最大数,若相等则输出 ...
- 计蒜客 28319.Interesting Integers-类似斐波那契数列-递推思维题 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 I)
I. Interesting Integers 传送门 应该是叫思维题吧,反正敲一下脑壳才知道自己哪里写错了.要敢于暴力. 这个题的题意就是给你一个数,让你逆推出递推的最开始的两个数(假设一开始的两个 ...
- 计蒜客 28317.Growling Gears-一元二次方程的顶点公式 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 G)
G. Growling Gears 传送门 此题为签到题,直接中学的数学知识点,一元二次方程的顶点公式(-b/2*a,(4*a*c-b*b)/4*a):直接就可以得到结果. 代码: #include& ...
- Benelux Algorithm Programming Contest 2014 Final
// Button Bashing (bfs) 1 #include <iostream> #include <cstdio> #include <cstring> ...
随机推荐
- Asp.net MVC Session过期异常的处理
一.使用MVC中的Filter来对Session进行验证 (1)方法1: public class MyAuthorizeAttribute : FilterAttribute, IAuthoriza ...
- 使用wcf的双工模式做的一个控制台聊天app
//wcf 服务 using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Ser ...
- MySQL指令
在mysql里:文件夹就是数据库 文件就是表 创建用户: 格式:create user '用户名'@'IP地址' identified by '密码'; 说明:IP地址是用来限制用户只能在哪 ...
- Java EE之Form的get与post方法
Form表单中method="post/get'的区别 Form提供了两种数据传输的方式——get和post.虽然它们都是数据的提交方式,但是在实际传输时确有很大的不同,并且可能会对数据产生 ...
- Ubuntu16.04安装搜狗拼音输入法(中文输入法)
虽然网上有很多教程,但是我觉得我的很适合那些真正的小白... 1.下载文件 由于我要给多台电脑安装搜狗输入法,所以用的是文件夹安装,不是命令行安装. 打开官网http://pinyin.sogou.c ...
- HDU1875 畅通工程再续【最小生成树】
题意: 在这些小岛中建设最小花费的桥,但是一座桥的距离必须在10 -- 1000之间. 思路: 用最小生成树解决吧,就那两个算法. 代码: prim #include <iostream> ...
- vue pc端网站项目开发坑点与难度记录
背景 在一pc端的web项目里,由于某些特性需要由动态语言处理,所以只在有需要使用vue来处理数据的页面,直接引入vue.js来处理.由于刚开始并没有打算使用前端来渲染数据和处理交互,所以使用了一些非 ...
- maven阿里云镜像
<mirrors> <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorO ...
- 一个有趣的小例子,带你入门协程模块-asyncio
一个有趣的小例子,带你入门协程模块-asyncio 上篇文章写了关于yield from的用法,简单的了解异步模式,[https://www.cnblogs.com/c-x-a/p/10106031. ...
- redis拾趣(客户端连接,keys命令,数据备份,缓存有效期等)
1.客户端连接 为了安全保护,redis支持绑定IP跟端口,这个通过conf配置文件中的bind跟port来设置. 绑定后登录client控制台时就需要写明ip(或者hostname)跟端口了,如: ...