您的位置:首页 > 其它

【bzoj4143】[AMPPZ2014]The Lawyer

2015-10-06 20:41 399 查看
这是noip–难度吧。。。。。

把第i天的所有左端点排序,然后upper_bound右端点就行了。

唔。。。。。。。。。。

[code]#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_pair

inline 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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: