码迷,mamicode.com
首页 > 其他好文 > 详细

Bzoj 4143: [AMPPZ2014]The Lawyer

时间:2019-01-13 17:09:33      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:amp   long   ring   ret   博客   putc   --   max   algorithm   

Bzoj 4143: [AMPPZ2014]The Lawyer

抱歉,水了这一片博客..( ~~ 为了凑出AMPPZ2014.... ~~

显然记录最小的右端点,和最大的左端点即可.

/*header*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i , x, p) for(int i = x;i <= p;++ i)
#define sep(i , x, p) for(int i = x;i >= p;-- i)
#define gc getchar()
#define pc putchar
#define ll long long
#define mk make_pair
#define fi first
#define se second
using std::min;
using std::max;
using std::swap;

inline int gi() {
    int x = 0,f = 1;char c = gc;
    while(c < '0' || c > '9') {if(c == '-')f = -1;c = gc;}
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0';c = gc;}return x * f;
}

void print(int x) {
    if(x < 0) pc('-') , x = -x;
    if(x >= 10) print(x / 10);
    pc(x % 10 + '0');
}

int max_d[23] , min_d[23];
int idmax_d[23] , idmin_d[23];

void gmin(int &x , int y) {x = x > y ? y : x;}
void gmax(int &x , int y) {x = x > y ? x : y;}

int main() {
    int n = gi() , m = gi();
    rep(i , 1, m) max_d[i] = -1e9 , min_d[i] = 1e9;
    rep(i , 1, n) {
        int l = gi() , r = gi(), d = gi();
        if(max_d[d] < l) {idmax_d[d] = i;max_d[d] = l;}
        if(min_d[d] > r) {idmin_d[d] = i;min_d[d] = r;}
    }
    rep(i , 1, m) {
        if(max_d[i] <= min_d[i]) puts("NIE");
        else {
            printf("TAK %d %d\n", idmin_d[i],idmax_d[i]);
        }
    }
    return 0;
}

Bzoj 4143: [AMPPZ2014]The Lawyer

标签:amp   long   ring   ret   博客   putc   --   max   algorithm   

原文地址:https://www.cnblogs.com/gzygzy/p/10263121.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!