题目链接: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. quartz.net使用(通过配置文件进行配置)

    在项目Nuget包管理器中搜索:quartz,安装完成之后再项目中引用即可 先定义一个Job,需要实现IJob接口: public class TestJob : IJob { public void ...

  2. 『HTMl5』学习日志

    w3g提供在线校验页面:http://validator.w3.org/ 1.文本框获取焦点 <%@ page language="java" import="ja ...

  3. POI设置excel某列值为文本格式

    excel单元格格式默认为[常规],当某列限定必须从下拉框选择一个纯数字文本的时候,必须将单元格格式设置为[文本]. 否则即使输入的值和下拉框的一致,excel都认为输入的值是常规类型,而下拉框的值为 ...

  4. selenium系列------元素定位套路

    selenium定位分为上三门,平三门,下三门, id,name,linktext上三门, class ,css,js平三门, xpath,tag名,复数定位(定位一组然后选index元素).

  5. Java学习记录 : 画板的实现

    接触java不满一个月,看厚厚的java入门简直要醉,故利用实例来巩固所学知识. 画板的实现其实从原理来说超级简单,可能一会儿就完成了. 但作为一名强迫症患者,要实现和win下面的画板一样的功能还是需 ...

  6. AJAX 处理xml 数据

    //这个方式返回的得是 xml标准的对象,可以返回 xml字符串,前端js 使用转为xml   function createXml(str){ if(document.all){//IE浏览器 va ...

  7. wait与sellp方法区别

    Java Thread(线程)案例详解sleep和wait的区别    上次对Java Thread有了总体的概述与总结,当然大多都是理论上的,这次我将详解Thread中两个常用且容易疑惑的方法.并通 ...

  8. 团队作业8——Beta项目(冲刺计划)

    Beta阶段冲刺计划 经过几周的努力我们完成了Alpha的开发,进过一段时间的调整与重组我们继续向Beta版进发. 1. 新成员介绍 林乔桦(201421123074):掌握c语言,JavaScrip ...

  9. 201521123036 《Java程序设计》第8周学习总结

    本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 1.2 选做:收集你认为有用的代码片段 HashMap自定义排序 List<Map.Entry<Stri ...

  10. 201521123047 《Java程序设计》第4周学习总结

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