【bzoj4143】[AMPPZ2014]The Lawyer
来源:互联网 发布:淘宝图片数据包 编辑:程序博客网 时间:2024/06/05 20:50
这是noip–难度吧。。。。。
把第i天的所有左端点排序,然后upper_bound右端点就行了。
唔。。。。。。。。。。
#include <bits/stdc++.h>using namespace std;#define rep(i,a,b) for(int i=a;i<=b;i++)#define per(i,a,b) for(int i=a;i>=b;i--)#define pii pair<int , int>#define mp make_pairinline int rd() { char c = getchar(); while (!isdigit(c)) c = getchar() ; int x = c - '0'; while (isdigit(c = getchar())) x = x * 10 + c - '0'; return x;}const int maxn = 500005;set<pii> S[21];int a[maxn] , b[maxn] , d[maxn] , vis[21] , m , n;pii ans[21];void input() { n = rd() , m = rd(); rep(i , 1 , n) { a[i] = rd() , b[i] = rd() , d[i] = rd(); S[d[i]].insert(mp(a[i] , i)); }}void solve() { rep(i , 1 , n) if (!vis[d[i]]) { set<pii>::iterator iter = S[d[i]].upper_bound(mp(b[i] , n + 1)); if (iter == S[d[i]].end()) continue; ans[d[i]].first = iter -> second , ans[d[i]].second = i; vis[d[i]] = 1; } rep(i , 1 , m) if (vis[i]) printf("TAK %d %d\n" , ans[i].first , ans[i].second); else puts("NIE");}int main() { #ifndef ONLINE_JUDGE// freopen("data.txt" , "r" , stdin); #endif input(); solve(); return 0;}
0 0
- 【AMPPZ2014】【BZOJ4143】The Lawyer
- 【bzoj4143】[AMPPZ2014]The Lawyer
- 【bzoj4152】[AMPPZ2014]The Captain
- 【bzoj4145】[AMPPZ2014]The Prices
- 【AMPPZ2014】【BZOJ4145】The Prices
- 【bzoj4151】 [AMPPZ2014]The Cave
- 【AMPPZ2014】【BZOJ4152】The Captain
- 【AMPPZ2014】【BZOJ4151】The Cave
- [BZOJ4145] [AMPPZ2014]The Prices
- 【bzoj4152】【AMPPZ2014】The Captain
- 4152: [AMPPZ2014]The Captain
- bzoj4145 [AMPPZ2014]The Prices
- 4152: [AMPPZ2014]The Captain
- [bzoj4145][AMPPZ2014]The Prices
- BZOJ4145: [AMPPZ2014]The Prices
- bzoj4152 [AMPPZ2014]The Captain
- 4152: [AMPPZ2014]The Captain
- BZOJ 4152: [AMPPZ2014]The Captain
- stl set
- 『2017年高考』
- ACM,动态规划,可怜的绵羊问题
- 默然日记20151006
- 带最小值操作的栈
- 【bzoj4143】[AMPPZ2014]The Lawyer
- Java三星题之剪刀石头布(三局两胜)
- 开发中使用过的设计模式
- 设计 4 个线程, 其中两个线程每次对 j 增加 1 , 另外两个线程对 j 每次减少 1 。 写出程序
- 为何加入:private static final long serialVersionUID
- FZU 2198 快来快来数一数(矩阵快速幂)
- 【BZOJ1630】【Usaco2008 Nov】【Time Management 时间管理】【贪心】
- 定时器+反射变换 --->模拟一个音乐播放器的音乐专辑旋转
- 【Python】Learn Python the hard way, ex0 学习使用Terminal