Bzoj 4143: [AMPPZ2014]The Lawyer
阿新 • • 發佈:2019-01-13
getchar sin tchar cstring min har sep else include
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