题目链接: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. JavaScript在应用中的技巧(一)

    分享一些在JavaScript中遇到的一些实用的技巧. 理解JavaScript的数值型数据类型 JavaScript的数值型数据类型只有一种:number.即不管是整数还是浮点数,JavaScrip ...

  2. 构建具有用户身份认证的 React + Flux 应用程序

    原文:Build a React + Flux App with User Authentication 译者:nzbin 译者的话:这是一篇内容详实的 React + Flux 教程,文章主要介绍了 ...

  3. JUnit 3.8.1 源码学习

    JUnit 3.8.1 源码学习 环境搭建(源码加载配置) 由于IDE自身含有JUint插件,因此通过正常途径是没有源码加载入口的,因此需通过手动加载扩展JAR,然后再添加对应源码JAR,如图:项目右 ...

  4. 附录:MySQL忘记root密码

    中小型规模网站集群架构:MySQL忘记root密码 : 矮哥linux运维群:93324526 前言 你忘记系统root密码的时候,你怎么解决的? 不就是single用户进行修改密码吗?这里原理是类似 ...

  5. MPLS LDP随堂笔记2

    前一天排错 Acl 1 匹配所有ospf的数据包 (目的 ospf建立邻居关系 传递路由条目) 2 放行UDP报文 让LDP邻居能互相收发HELLO包 4 放行TCP报文 让LDP邻居能够建立TCP会 ...

  6. 团队作业8——第二次项目冲刺(Beta阶段)--5.24 forth day

    团队作业8--第二次项目冲刺(Beta阶段)--5.24 forth day Day four: 会议照片 项目进展 Beta冲刺的第四天,以下是今天具体任务安排: 队员 昨天已完成的任务 今日计划完 ...

  7. Android中显示和隐式Intent的使用

    显示启动activity                                                                                         ...

  8. Java:实现对象的比较 comparable接口和comparator接口

    在实际应用中,我们往往有需要比较两个自定义对象大小的地方.而这些自定义对象的比较,就不像简单的整型数据那么简单,它们往往包含有许多的属性,我们一般都是根据这些属性对自定义对象进行比较的.所以Java中 ...

  9. Spring Boot Maven Plugin(一):repackage目标

    简介 Spring Boot Maven Plugin插件提供spring boot在maven中的支持.允许你打包可运行的jar包或war包. 插件提供了几个maven目标和Spring Boot ...

  10. Oracle函数之chr

    chr()函数将ASCII码转换为字符:字符 –> ASCII码:ascii()函数将字符转换为ASCII码:ASCII码 –> 字符: 在oracle中chr()函数和ascii()是一 ...