题目链接:

  http://codeforces.com/gym/100526

  http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11668&courseid=0

题目大意:

  N个人,每个人有三个能力排名X Y Z,每种能力没有同名次,如果当前的人比在清单上的人中至少有一项能力都要优,则这个人也会被加到清单上。

  求最终清单上有几个人。(N<=100000)

题目思路:

  【线段树】

  首先按第三关键字排序,确定一维的大小关系,接下来如果(X,Y)中的其中一个比之前的人都要优,则这个人就会被添加。

  考虑用a[X]表示1到X中最小的Y值,则只需要比较Y和a[X]的大小就能确定出是否需要添加这个人。

  用线段树记录区间最小Y值,并且实时更新。

 //
//by coolxxx
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define mem(a,b) memset(a,b,sizeof(a))
#define eps (1e-8)
#define J 10
#define mod 1000000007
#define MAX 0x7f7f7f7f
#define PI 3.14159265358979323
#define N 100004
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
struct xxx
{
int x,y,z;
}a[N];
int t[N<<];
bool cmp(xxx aa,xxx bb)
{
return aa.x<bb.x;
}
void change(int l,int r,int x,int c,int k)
{
if(l>r || x<l || x>r)return;
if(l==r){t[k]=c;return;}
change(l,(l+r)>>,x,c,k+k);
change((l+r)/+,r,x,c,k+k+);
t[k]=min(t[k+k],t[k+k+]);
}
int query(int l,int r,int a,int b,int k)
{
if(l>r || l>b || r<a)return MAX;
if(a<=l && r<=b)return t[k];
int x1=query(l,(l+r)>>,a,b,k+k),x2=query((l+r)/+,r,a,b,k+k+);
return t[k]=min(x1,x2);
}
int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j,k;
for(scanf("%d",&cas);cas;cas--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s+1))
// while(~scanf("%d",&n))
{
ans=;mem(t,0x7f);
scanf("%d",&n);
for(i=;i<=n;i++)
scanf("%d%d%d",&a[i].y,&a[i].z,&a[i].x);
sort(a+,a++n,cmp);
change(,n,a[].y,a[].z,);
for(i=;i<=n;i++)
{
j=query(,n,,a[i].y,);
if(j>a[i].z)ans++;
change(,n,a[i].y,a[i].z,);
}
printf("%d\n",ans);
}
return ;
}
/*
// //
*/

【线段树】BAPC2014 E Excellent Engineers (Codeforces GYM 100526)的更多相关文章

  1. 【扩展欧几里得】BAPC2014 I Interesting Integers (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  2. 【宽搜】BAPC2014 J Jury Jeopardy (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  3. 【模拟】BAPC2014 G Growling Gears (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  4. 【最短路】BAPC2014 B Button Bashing (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  5. 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  6. 【最大流】BAPC2014 A Avoiding the Apocalypse (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  7. (线段树 && 字符串的处理)codeforces -- 570C

    链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87813#problem/J Description Daniel has a s ...

  8. 区间->点,点->区间,线段树优化建图+dijstra Codeforces Round #406 (Div. 2) D

    http://codeforces.com/contest/787/problem/D 题目大意:有n个点,三种有向边,这三种有向边一共加在一起有m个,然后起点是s,问,从s到所有点的最短路是多少? ...

  9. Codeforces Gym 100803G Flipping Parentheses 线段树+二分

    Flipping Parentheses 题目连接: http://codeforces.com/gym/100803/attachments Description A string consist ...

随机推荐

  1. Android常用第三方框架

    1.volley (截击) 项目地址 https://github.com/smanikandan14/Volley-demo (1)  JSON,图像等的异步下载: (2)  网络请求的排序(sch ...

  2. ASP.NET Excel数据导出数据库

    /// <summary> /// 根據gridview導出excel /// </summary> /// <param name="ctl"> ...

  3. 分享整理的sql脚本

    1. 表空间使用率 SQL> select  a.tablespace_name,  2          round(a.total_size) "total_size M" ...

  4. UIView下使用Animation控制动画

    转载自:http://blog.csdn.net/xunyn/article/details/8128031 动画效果是IOS界面重要的特色之一,其中CAAnimation是所有动画对象的抽象父类,作 ...

  5. node-http-proxy修改响应结果

    最近在项目中使用node-http-proxy遇到需要修改代理服务器响应结果需求,该库已提供修改响应格式为html的方案:Harmon,而项目中返回格式统一为json,使用它感觉太笨重了,所以自己写了 ...

  6. centos7上安装与配置Tomcat7(整理篇)

    1.检查tomcat7是否已经安装 rpm -qa | grep tomcat ps -ef | grep tomcat 第一条命令查看是用rpm安装过tomcat,由于我们倾向于安装解压版的tomc ...

  7. mac 自带 php 验证码 不显示

    curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5 在命令行中输入上面   ,最后5.5是php版本号 自动安装FreeType ----- ...

  8. utf8_general utf8_general utf8_bin区别

    对与general来说 ß = s 是为true的 但是对于unicode来说 ß = ss 才是为true的, 其实他们的差别主要在德语和法语上,所以对于我们中国人来说,一般使用general,因为 ...

  9. DOS命令行使用pscp实现远程文件和文件夹传输(转)

    转自 http://snailwarrior.blog.51cto.com/680306/141201   pscp是putty安装包所带的远程文件传输工具,使用和Linux下scp命令相似,具体的使 ...

  10. 离散傅里叶变换(DFT)

    目录     一.研究的意义     二.DFT的定义    三.DFT与傅里叶变换和Z变换的关系     四.DFT的周期性     五.matlab实验       五.1 程序         ...