Description

Byteasar要制订m天的会议计划,一共有n场会议,第i场会议开始于第d[i]天的第a[i]秒,结束于第d[i]天的第b[i]秒。
对于每一天,请找出这一天的两场会议i,j,使得它们不冲突,即不存在一个数k同时满足a[i]<=k<=b[i]以及a[j]<=k<=b[j]。
 

Input

第一行包含两个正整数n,m(2<=n<=500000,1<=m<=20),表示会议的场数和天数。
接下来n行,每行包含三个正整数a[i],b[i],d[i](1<=a[i]<b[i]<=80000000,1<=d[i]<=m),描述一场会议。
 

Output

输出m行。第i行输出第i天的答案,如果无解,输出NIE,否则输出TAK,然后输出这一天参加的两场会议的编号,
如有多组解,输出任意一组。
 

Sample Input

6 3
3 5 1
2 4 2
1 8 1
6 7 3
3 5 2
7 12 1

Sample Output

TAK 1 6
NIE
NIE

这真的是BZOJ上的题?
用邻接边将每天的会议串起来,因为任意一个方案即可,扫一遍取左端点的最大值,右端点的最小值,判判即可。

#include<cstdio>
#include<cctype>
#include<queue>
#include<cstring>
#include<algorithm>
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define ren for(int i=first[x];i!=-1;i=next[i])
using namespace std;
inline int read() {
int x=,f=;char c=getchar();
for(;!isdigit(c);c=getchar()) if(c=='-') f=-;
for(;isdigit(c);c=getchar()) x=x*+c-'';
return x*f;
}
const int maxn=;
struct Conference {int s,t;}A[maxn];
int first[],next[maxn],e,num[maxn];
void Add(int x,int v) {
num[++e]=v;next[e]=first[x];first[x]=e;
}
int n,m;
int main() {
n=read();m=read();
rep(i,,n) A[i].s=read(),A[i].t=read(),Add(read(),i);
rep(i,,m) {
int a=num[first[i]],b=a,cnt=;
for(int j=first[i];j;j=next[j]) {
if(A[num[j]].s>A[a].s) a=num[j];
if(A[num[j]].t<A[b].t) b=num[j];
cnt++;
}
if(cnt<||A[a].s<=A[b].t) puts("NIE");
else printf("TAK %d %d\n",a,b);
}
return ;
}

BZOJ4143 [AMPPZ2014]The Lawyer的更多相关文章

  1. BZOJ 4143: [AMPPZ2014]The Lawyer( sort )

    水题... 排序搞出每天的会议有哪些, 然后再按照会议的开始时间和结束时间排序, 最晚开始的和最早结束的会议不是同一场而且最晚开始的时间>最早结束的会议就有可能方案 -------------- ...

  2. AMPPZ2014

    [AMPPZ2014]The Lawyer 记录每天结束的最早的会议以及开始的最晚的会议即可. #include<cstdio> #define N 500010 int n,m,i,d, ...

  3. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  4. BZOJ 4144: [AMPPZ2014]Petrol

    4144: [AMPPZ2014]Petrol Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 457  Solved: 170[Submit][Sta ...

  5. 循环队列+堆优化dijkstra最短路 BZOJ 4152: [AMPPZ2014]The Captain

    循环队列基础知识 1.循环队列需要几个参数来确定 循环队列需要2个参数,front和rear 2.循环队列各个参数的含义 (1)队列初始化时,front和rear值都为零: (2)当队列不为空时,fr ...

  6. BZOJ 4152: [AMPPZ2014]The Captain( 最短路 )

    先按x排序, 然后只有相邻节点的边才有用, 我们连起来, 再按y排序做相同操作...然后就dijkstra ---------------------------------------------- ...

  7. BZOJ 4145: [AMPPZ2014]The Prices( 状压dp + 01背包 )

    我自己只能想出O( n*3^m )的做法....肯定会T O( nm*2^m )做法: dp( x, s ) 表示考虑了前 x 个商店, 已买的东西的集合为s. 考虑转移 : 先假设我们到第x个商店去 ...

  8. bzoj4152[AMPPZ2014]The Captain 最短路

    4152: [AMPPZ2014]The Captain Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 1517  Solved: 603[Submi ...

  9. [AMPPZ2014]Jaskinia

    [AMPPZ2014]Jaskinia 题目大意: 一个\(n(n\le3\times10^5)\)的树,\(m(m\le3\times10^5)\)个约束条件\((a_i,b_i,d_i)\).请你 ...

随机推荐

  1. HDOJ 2095

    find your present (2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/1024 K (Java/Oth ...

  2. 初中数学题归纳w

    刷完了一张代数 P1 计算 $\left( \frac{1}{1}-\frac{1}{2}+\frac{1}{3}-\frac{1}{4}+...+\frac{1}{2011}- \frac{1}{2 ...

  3. 【SpringMVC】SpringMVC系列14之SpringMVC国际化

    14.SpringMVC国际化 14.1.概述 14.2.用户切换选择语言

  4. Recover Rotated Sorted Array

    Given a rotated sorted array, recover it to sorted array in-place. Clarification What is rotated arr ...

  5. iOS 和 Android 触摸事件传递

    先看文章,写得很好 ios 触摸事件传递 http://www.cnblogs.com/Quains/p/3369132.html 另外一篇 http://blog.csdn.net/yongyinm ...

  6. mysql 我的学习

    安装要求 安装环境:CentOS-6.3安装方式:源码编译安装 软件名称:mysql-cluster-gpl-7.2.6-linux2.6-x86_64.tar.gz下载地址:http://mysql ...

  7. Java for LeetCode 171 Excel Sheet Column Number

    Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, retur ...

  8. hdu 1113 Word Amalgamation 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 题意:输入一个字典,然后再输入若干单词(每行中,1 <= 单词数 <= 100,并且 ...

  9. July 24th, Week 31st Sunday, 2016

    Miracles happen every day. 奇迹每天都在发生. Miracles actually happen every day, every moment. You may think ...

  10. javascript十六进制数字和ASCII字符之间转换

    var hex="0x29";//十六进制 var charValue = String.fromCharCode(hex);//生成Unicode字符 var charCode ...