题目链接: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的更多相关文章

  1. 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 ...

  2. 2018 Benelux Algorithm Programming Contest (BAPC 18)I In Case of an Invasion, Please. . .

    题意:一副无向有权图,每个点有一些人,某些点是避难所(有容量),所有人要去避难所,问最小时间所有人都到达避难所, 题解:dij+二分+最大流check,注意到避难所最多10个,先挨个dij求到避难所的 ...

  3. Gym -102007 :Benelux Algorithm Programming Contest (BAPC 18) (寒假自训第5场)

    A .A Prize No One Can Win 题意:给定N,S,你要从N个数中选最多是数,使得任意两个之和不大于S. 思路:排序,然后贪心的选即可. #include<bits/stdc+ ...

  4. 2017 Benelux Algorithm Programming Contest (BAPC 17) Solution

    A - Amsterdam Distance 题意:极坐标系,给出两个点,求最短距离 思路:只有两种方式,取min  第一种,先走到0点,再走到终点 第二种,走到同一半径,再走过去 #include ...

  5. 2015 Benelux Algorithm Programming Contest (BAPC 15)E - Excellent Engineers

    这题想了很久没思路,不知道怎么不sort维护二维的最小值 emmmm原来是线段树/树状数组,一维sort,二维当成下标,维护三维的最小值 #include<bits/stdc++.h> # ...

  6. Benelux Algorithm Programming Contest 2014 Final(第二场)

    B:Button Bashing You recently acquired a new microwave, and noticed that it provides a large number ...

  7. 03.14 ICPC训练联盟周赛,Preliminaries for Benelux Algorithm Programming Contest 2019

    A .Architecture 题意:其实就是想让你找到两行数的最大值,然后比较是否相同,如果相同输出'possible',不同则输出'impossible' 思路:直接遍历寻找最大值,然后比较即可 ...

  8. 计蒜客 28319.Interesting Integers-类似斐波那契数列-递推思维题 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 I)

    I. Interesting Integers 传送门 应该是叫思维题吧,反正敲一下脑壳才知道自己哪里写错了.要敢于暴力. 这个题的题意就是给你一个数,让你逆推出递推的最开始的两个数(假设一开始的两个 ...

  9. 计蒜客 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& ...

随机推荐

  1. java 得到以后的日期

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt222 import java.text.ParseException; im ...

  2. 第3阶段——内核启动分析之start_kernel初始化函数(5)

    内核启动分析之start_kernel初始化函数(init/main.c) stext函数启动内核后,就开始进入start_kernel初始化各个函数, 下面只是浅尝辄止的描述一下函数的功能,很多函数 ...

  3. jQuery插件——ajax

    一.ajax请求 1.load(url, [data], [callback]) 概述:加载远程的HTML文件代码,并插入到指定的DOM节点中. 参数:url:待装入 HTML 网页网址. data: ...

  4. MySQLzip archive版本(5.7.19)安装教程

    1.  从官网下载zip archive版本http://dev.mysql.com/downloads/mysql/ 2. 解压缩至相应目录,并配置环境变量(将*\bin添加进path中): 3. ...

  5. Alpha个人总结

    一.我的问题: 1.第一章1.2.1 在软件的特殊性中说到,"大型软件有超过数百万行的源代码,上万个不同的文件,而软件工程师通常一次只能看到30-80行源代码,他们的智力.记忆力和常人差不多 ...

  6. 201521123031 《Java程序设计》第4周学习总结

    ---恢复内容开始--- 1. 本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内容. (1)父类只能有一个,即单继承,子类继承父类的全部成员(属性和方法 ...

  7. 201521123033《Java程序设计》第4周学习总结

    1. 本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. answer: 1.2 使用常规方法总结其他上课内容. answer:学了继承以及各种关键字 2. 书面作业 1.注释的应用 使用类 ...

  8. 201521123044 《Java程序设计》第2周作业-Java基本语法与类库

    1. 本章学习总结 ·1.浮点型的不精确,不能简单的像C语言一样用float或者double来定义.在java中有更精确的BigDecimal类. 举例:BigDecimal bd1= new Big ...

  9. 201521123074 《Java程序设计》第12周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 2. 书面作业 Q1.将Student对象(属性:int id, String name,int age,do ...

  10. NA笔记

    常用配置命令 mstsc 远程桌面控制指令(在运行中输入) cmd 运行 copy running-config start 正在启动文件 copy running-config startup-ci ...