1.LA 5694 Adding New Machine
关键词:数据结构,线段树,扫描线(FIFO)
1 #include <algorithm> 2 #include <cstdio> 3 #include <cstring> 4 #include <string> 5 #include <queue> 6 #include <map> 7 #include <set> 8 #include <ctime> 9 #include <cmath> 10 #include <iostream> 11 #define pi acos(-1.) 12 using namespace std; 13 typedef long long ll; 14 const int int_inf = 0x3f3f3f3f; 15 const ll ll_inf = 1ll << 62; 16 const int INT_INF = (int)((1ll << 31) - 1); 17 const int mod = 1e6 + 7; 18 const double double_inf = 1e30; 19 typedef unsigned long long ul; 20 #pragma comment(linker, "/STACK:102400000,102400000") 21 #define max(a, b) ((a) > (b) ? (a) : (b)) 22 #define min(a, b) ((a) < (b) ? (a) : (b)) 23 #define mp make_pair 24 #define st first 25 #define nd second 26 #define keyn (root->ch[1]->ch[0]) 27 #define lson (u << 1) 28 #define rson (u << 1 | 1) 29 #define pii pair<int, int> 30 #define pll pair<ll, ll> 31 #define pb push_back 32 #define type(x) __typeof(x.begin()) 33 #define foreach(i, j) for(type(j)i = j.begin(); i != j.end(); i++) 34 #define FOR(i, s, t) for(int i = (s); i <= (t); i++) 35 #define ROF(i, t, s) for(int i = (t); i >= (s); i--) 36 #define dbg(x) cout << x << endl 37 #define dbg2(x, y) cout << x << " " << y << endl 38 #define clr(x, i) memset(x, (i), sizeof(x)) 39 #define maximize(x, y) x = max((x), (y)) 40 #define minimize(x, y) x = min((x), (y)) 41 42 inline int readint(){ 43 bool neg = 0; char ch, t[11]; 44 int k = 0; 45 while((ch = getchar()) == ' ' || ch == ' ' || ch == 9) ; 46 neg = ch == '-'; 47 ch == '-' ? neg = 1 : t[k++] = ch; 48 while((ch = getchar()) >= '0' && ch <= '9') t[k++] = ch; 49 //__ch = ch; 50 int x = 0, y = 1; 51 while(k) x += (t[--k] - '0') * y, y *= 10; 52 return neg ? -x : x; 53 } 54 55 inline int readstr(char *s){ 56 char ch; 57 int len = 0; 58 while((ch = getchar()) == ' ' || ch == ' ' || ch == 9) ; 59 if(ch == EOF) return 0; 60 *(s++) = ch, ++len; 61 while((ch = getchar()) != ' ' && ch != ' ' && ch != EOF) *(s++) = ch, ++len; 62 *s = '