2014 Benelux Algorithm Programming Contest (BAPC 14)E
题目链接:https://vjudge.net/contest/187496#problem/E
E Excellent Engineers
You are working for an agency that selects the best software engineers from Belgium, the Netherlands and Luxembourg for employment at various international companies. Given the very large number of excellent software engineers these countries have to offer, the agency has charged you to develop a tool that quickly selects the best candidates available from the agency’s files. Before a software engineer is included in the agency’s files, he has to undergo extensive testing. Based on these tests, all software engineers are ranked on three essential skills: communication skills, programming skills, and algorithmic knowledge. The software engineer with rank one in the category algorithmic knowledge is the best algorithmic expert in the files, with rank two the second best, etcetera. For potential customers, your tool needs to process the agency’s files and produce a shortlist of the potentially most interesting candidates. A software engineer is a potential candidate that is to be put on this shortlist if there is no other software engineer in the files that scores better on all three skills. That is, an engineer is to be put on the shortlist if there is no other software engineer that has better communication skills, better programming skills, and more algorithmic knowledge.
Input On the first line one positive number: the number of test cases, at most 100. After that per test case: • one line with a single integer n (1 ≤ n ≤ 100 000): the number of software engineers in the agency’s files. • n lines, each with three space-separated integers r1, r2 and r3 (1 ≤ r1, r2, r3 ≤ n): the rank of each software engineer from the files with respect to his communication skills, programming skills and algorithmic knowledge, respectively. For each skill s and each rank x between 1 and n, there is exactly one engineer with rs = x. 10 Problem E: Excellent Engineers Output Per test case: • one line with a single integer: the number of candidates on the shortlist.
Sample in- and output
Input Output
3 3 1
2 3 2 3
3 2 3 7
1 1 1
3
1 2 3
2 3 1
3 1 2
10
1 7 10
3 9 7
2 2 9
5 10 8
4 3 5
7 5 2
6 1 3
9 6 6
8 4 4
10 8 1
题意:给出N,个人在三个方面(a,b,c)的名次,问你没有一个人名次在三个方面都比某个人好的个数。
题解:先用结构体按a从小到大排序,然后建一个线段树,在b位置的值对应c,先把线段树初始化为inf,然后按结构排好的顺序每次对b位置的值更新为c,判断某个人是否合适只要看线段树
从1~b的最小值是否小于自己的C值
复杂度为(N*log(N))
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define PI 3.14159265
using namespace std;
const int maxn=1e5+;
const int inf=0x3f3f3f3f;
int t,n;
int sd[maxn];
int tree[maxn<<];
struct node
{
int a,b,c;
bool operator<(const node d)const
{
return a<d.a;
}
}st[maxn];
void update(int loc,int num,int l,int r,int rt)
{
if(l==r)
{
tree[rt]=num;
return ;
}
int mid=(l+r)>>;
if(loc>mid)update(loc,num,mid+,r,rt<<|);
else update(loc,num,l,mid,rt<<);
tree[rt]=min(tree[rt<<],tree[rt<<|]);
return;
}
int query(int L,int R,int l,int r,int rt)
{
// cout<<L<<' '<<R<<" "<<l<<" "<<r<<" "<<rt<<endl;
if(L<=l&&r<=R)
{ return tree[rt];
}
int m=(l+r)>>;
int ans=inf;
if(R>m)
ans=min(ans,query(L,R,m+,r,rt<<|));
if(L<=m)
ans=min(ans,query(L,R,l,m,rt<<));
return ans;
}
int main()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>t;
while(t--)
{
cin>>n;
for(int i=;i<n;i++)
{
cin>>st[i].a>>st[i].b>>st[i].c;
}
sort(st,st+n);int cnt=;
memset(tree,inf,sizeof(tree));
update(st[].b,st[].c,,n,);
for(int i=;i<n;i++)
{
if(st[i].b==)
{
update(st[i].b,st[i].c,,n,);
continue;
}
int tmp=query(,st[i].b-,,n,);
// cout<<tmp<<endl;
update(st[i].b,st[i].c,,n,);
if(tmp<st[i].c)cnt++;
}
cout<<n-cnt<<endl;
} return ;
}
2014 Benelux Algorithm Programming Contest (BAPC 14)E的更多相关文章
- 2018 Benelux Algorithm Programming Contest (BAPC 18)
目录 Contest Info Solutions A A Prize No One Can Win B Birthday Boy C Cardboard Container D Driver Dis ...
- 2018 Benelux Algorithm Programming Contest (BAPC 18)I In Case of an Invasion, Please. . .
题意:一副无向有权图,每个点有一些人,某些点是避难所(有容量),所有人要去避难所,问最小时间所有人都到达避难所, 题解:dij+二分+最大流check,注意到避难所最多10个,先挨个dij求到避难所的 ...
- Gym -102007 :Benelux Algorithm Programming Contest (BAPC 18) (寒假自训第5场)
A .A Prize No One Can Win 题意:给定N,S,你要从N个数中选最多是数,使得任意两个之和不大于S. 思路:排序,然后贪心的选即可. #include<bits/stdc+ ...
- 2017 Benelux Algorithm Programming Contest (BAPC 17) Solution
A - Amsterdam Distance 题意:极坐标系,给出两个点,求最短距离 思路:只有两种方式,取min 第一种,先走到0点,再走到终点 第二种,走到同一半径,再走过去 #include ...
- 2015 Benelux Algorithm Programming Contest (BAPC 15)E - Excellent Engineers
这题想了很久没思路,不知道怎么不sort维护二维的最小值 emmmm原来是线段树/树状数组,一维sort,二维当成下标,维护三维的最小值 #include<bits/stdc++.h> # ...
- Benelux Algorithm Programming Contest 2014 Final(第二场)
B:Button Bashing You recently acquired a new microwave, and noticed that it provides a large number ...
- 03.14 ICPC训练联盟周赛,Preliminaries for Benelux Algorithm Programming Contest 2019
A .Architecture 题意:其实就是想让你找到两行数的最大值,然后比较是否相同,如果相同输出'possible',不同则输出'impossible' 思路:直接遍历寻找最大值,然后比较即可 ...
- 计蒜客 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& ...
随机推荐
- linux下tomcat作为daemon进程运行
在linux下如果想让tomcat在开机时自启动,可以将启动代码写到/etc/rc.local里面.但是,这样的话,tomcat将以root权限运行,这是不安全的.因此,要想办法让tomcat以非特权 ...
- 了解 Spring Boot AutoConfiguration
原文:http://sivalabs.in/2016/03/how-springboot-autoconfiguration-magic/ 作者:Siva 译者:http://oopsguy.com ...
- Thread类源码剖析
目录 1.引子 2.JVM线程状态 3.Thread常用方法 4.拓展点 一.引子 说来也有些汗颜,搞了几年java,忽然发现竟然没拜读过java.lang.Thread类源码,这次特地拿出来晒一晒. ...
- 栈的实现Java
package practice; import java.util.Iterator; //栈 public class MyStack<T> implements Iterable&l ...
- Spring Cloud在国内中小型公司能用起来吗?
今天吃完饭休息的时候瞎逛知乎,突然看到这个一个问题Spring Cloud在国内中小型公司能用起来吗?,吸引了我的注意.仔细的看了题主的问题,发现这是一个好问题,题主经过了一番思考,并且用图形全面的将 ...
- svn: Can't convert string from 'UTF-8' to native
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt227 svn 版本库中有文件是以中文字符命名的,在 Linux 下 chec ...
- 关于"设计模式“
夜深了,人静了,该写点儿东西了.这是第一篇博客,写点儿对设计模式的粗浅理解吧. 什么是设计模式? 上学那会儿初次听到这个名字一点儿概念都没有,不知道它是用来干嘛的,感觉听上去挺抽象的一个东西. 工 ...
- RMA退货流程解决方案
RMA退货流程解决方案 1.概述 在高科技制造业中有效地对产品退货进行控制和跟踪有很大的意义.对于一个产品成本从几元到几十万元的工业,管理退货流程的能力至关重要,缺乏跟踪和控制有可能导致上百万元的损失 ...
- 《Java程序设计》第1周学习总结
1.本周本章学习总结 感觉装环境和基础语言也没什么好总结的,就谈谈我对java的认识. 接触的语言也不多,c语言,python.去年科研立项立了个安卓开发的项.也有去学了一阶段java.由于种种原因没 ...
- 团队作业八-Beta版本冲刺计划及安排
Beta版本冲刺计划及安排 目录: 1.介绍小组新加入的成员,他担任的角色 2.下一阶段需要改进完善的功能 3.下一阶段新增(或修改)的功能 4.需要改进的团队分工 5.需要改进的工具流程 6.冲刺的 ...