BZOJ4143 [AMPPZ2014]The Lawyer
Description
Input
Output
Sample Input
3 5 1
2 4 2
1 8 1
6 7 3
3 5 2
7 12 1
Sample Output
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的更多相关文章
- BZOJ 4143: [AMPPZ2014]The Lawyer( sort )
水题... 排序搞出每天的会议有哪些, 然后再按照会议的开始时间和结束时间排序, 最晚开始的和最早结束的会议不是同一场而且最晚开始的时间>最早结束的会议就有可能方案 -------------- ...
- AMPPZ2014
[AMPPZ2014]The Lawyer 记录每天结束的最早的会议以及开始的最晚的会议即可. #include<cstdio> #define N 500010 int n,m,i,d, ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- BZOJ 4144: [AMPPZ2014]Petrol
4144: [AMPPZ2014]Petrol Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 457 Solved: 170[Submit][Sta ...
- 循环队列+堆优化dijkstra最短路 BZOJ 4152: [AMPPZ2014]The Captain
循环队列基础知识 1.循环队列需要几个参数来确定 循环队列需要2个参数,front和rear 2.循环队列各个参数的含义 (1)队列初始化时,front和rear值都为零: (2)当队列不为空时,fr ...
- BZOJ 4152: [AMPPZ2014]The Captain( 最短路 )
先按x排序, 然后只有相邻节点的边才有用, 我们连起来, 再按y排序做相同操作...然后就dijkstra ---------------------------------------------- ...
- BZOJ 4145: [AMPPZ2014]The Prices( 状压dp + 01背包 )
我自己只能想出O( n*3^m )的做法....肯定会T O( nm*2^m )做法: dp( x, s ) 表示考虑了前 x 个商店, 已买的东西的集合为s. 考虑转移 : 先假设我们到第x个商店去 ...
- bzoj4152[AMPPZ2014]The Captain 最短路
4152: [AMPPZ2014]The Captain Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 1517 Solved: 603[Submi ...
- [AMPPZ2014]Jaskinia
[AMPPZ2014]Jaskinia 题目大意: 一个\(n(n\le3\times10^5)\)的树,\(m(m\le3\times10^5)\)个约束条件\((a_i,b_i,d_i)\).请你 ...
随机推荐
- Count Primes
Count the number of prime numbers less than a non-negative number, n public int countPrimes(int n) { ...
- Jump Game | & ||
Jump Game | Given an array of non-negative integers, you are initially positioned at the first index ...
- Django中如何查找模板
参考:http://my.oschina.net/zuoan001/blog/188782 Django的setting中有关找模板的配置有如下两个: TEMPLATE_LOADERS TEMPLAT ...
- Kmin
Kmin of Array [本文链接] http://www.cnblogs.com/hellogiser/p/kmin-of-array.html [代码] C++ Code 12345678 ...
- 在eclipse中配置一个简单的spring入门项目
spring是一个很优秀的基于Java的轻量级开源框架,为了解决企业级应用的复杂性而创建的,spring不仅可用于服务器端开发,从简单性.可测试性和松耦合性的角度,任何java应用程序都可以利用这个思 ...
- MPlayer-ww 增加边看边剪切功能+生成高质量GIF功能
http://pan.baidu.com/s/1eQm5a74 下载FFmpeg palettegen paletteuse documentation 需要下载 FFmpeg2.6 以上 并FFmp ...
- Lubuntu下配置Python开发环境
安装完系统必须要做的几件事: 一.更新软件 (如果是通过最新版镜像安装,可无视此步骤) 1.选择速度比较快的源,默认的源速度不一定快.二.配置终端 1.设置终端背景,前景色,透明度 ...
- CodeForces - 417A(思维题)
Elimination Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- Android概述
- MVC系统学习3—ModelBinder
在ASP.NET MVC中,每个请求都被映射到一个Action方法,我们可以在action的方法中定义相应类型的参数,View中通过post.get方式提交的request参数,只要名称一致就会对应到 ...