結果
問題 | No.686 Uncertain LIS |
ユーザー | shadowYYH |
提出日時 | 2023-12-25 11:27:43 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,907 bytes |
コンパイル時間 | 2,203 ms |
コンパイル使用メモリ | 171,756 KB |
実行使用メモリ | 7,620 KB |
最終ジャッジ日時 | 2024-09-27 14:20:15 |
合計ジャッジ時間 | 5,407 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
ソースコード
#include <bits/stdc++.h> #define For(x, y, z) for (int x = y, x##E = z; x <= x##E; ++x) #define Rof(x, y, z) for (int x = y, x##E = z; x >= x##E; --x) #define Eor(u) for (int i = head[u]; i; i = nxt[i]) #define SZ(x) (int(x.size())) #define pb push_back using namespace std; using i64 = long long; using ull = unsigned long long; using pii = pair<int, int>; // char buf[(1<<21)+5],*p1,*p2; // #define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++) inline int read() { int x = 0, f = 0; char ch = getchar(); while (!isdigit(ch)) f |= (ch == '-'), ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return f ? -x : x; } int __stk[128], __tp; inline void put(i64 x) { if (x < 0) putchar('-'), x = -x; do { __stk[++__tp] = x % 10, x /= 10; } while (x); while (__tp) putchar(__stk[__tp--] + '0'); } const int mod = 998244353; inline int ksm(int x, int y, int res = 1) { for ( ; y; y >>= 1, x = 1ll * x * x % mod) (y & 1) && (res = 1ll * res * x % mod); return res; } inline int inv(int x) { return ksm(x, mod - 2); } inline int gcd(int a, int b) { if (b) while ((a %= b) && (b %= a)); return a | b; } inline void add(int &x, int y) { (x += y) >= mod && (x -= mod); } inline void Min(int &x, int y) { (y < x) && (x = y); } inline void Max(int &x, int y) { (y > x) && (x = y); } const int N = 2e6 + 1000; namespace FHQ { mt19937 R(114514); #define ls(x) (t[x].ls) #define rs(x) (t[x].rs) struct node { int ls, rs, siz, w, tag, rnd; }t[N]; int num, root, a, b, c, d; void pushup(int x) { t[x].siz = t[ls(x)].siz + t[rs(x)].siz + 1; } void update(int x, int v) { if (x) t[x].w += v, t[x].tag += v;} void pushdown(int x) { if (t[x].tag) update(ls(x), t[x].tag), update(rs(x), t[x].tag), t[x].tag = 0; } int New(int x) { return t[++num] = {0, 0, 1, x, 0, (int)R()}, num; } int merge(int x, int y) { if (!x || !y) return x | y; ;pushdown(x), pushdown(y); if (t[x].rnd < t[y].rnd) return rs(x) = merge(rs(x), y), pushup(x), x; return ls(y) = merge(x, ls(y)), pushup(y), y; } void split(int x, int k, int &a, int &b) { if (!x) return a = b = 0, void(); ;pushdown(x); if (t[ls(x)].siz >= k) b = x, split(ls(x), k, a, ls(b)); else a = x, split(rs(x), k - t[ls(x)].siz - 1, rs(a), b);;pushup(x); } int build(int l, int r) { if (l > r) return 0; int mid = (l + r) >> 1, x = New(0); if (l == r) return x; ls(x) = build(l, mid - 1); rs(x) = build(mid + 1, r), pushup(x); return x; } int get_mi(int x) { if (!x) return 0; while (pushdown(x), ls(x)) x = ls(x); return t[x].w; } int get_ma(int x) { if (!x) return 0; while (pushdown(x), rs(x)) x = rs(x); return t[x].w; } void modify(int x, int v) { while (x) { pushdown(x); if (t[x].w < v) update(ls(x), 1), t[x].w += 1, x = rs(x); else x = ls(x); } } void out(int x) { if (!x) return; pushdown(x); out(ls(x)); cout <<t[x].w <<" "; out(rs(x)); } void change(int l, int r) { split(root, r, b, c), split(b, l - 2, a, b); if (l == 1) { split(b, t[b].siz - 1, b, d), b = merge(New(0), b), update(b, 1); a = merge(a, b), modify(c, get_ma(b)), root = merge(a, c); } else { split(b, t[b].siz - 1, b, d), d = New(get_mi(b)), update(b, 1); a = merge(a, merge(d, b)), modify(c, get_ma(b)), root = merge(a, c); } } } signed main() { // freopen("lis.in", "r", stdin); // freopen("lis2.out", "w", stdout); int n = read(); FHQ::root = FHQ::build(1, 10); // FHQ::out(FHQ::root), cout << '\n'; while (n--) { int l = read(), r = read(); FHQ::change(l, r); // FHQ::out(FHQ::root), cout << '\n'; } cout << FHQ::get_ma(FHQ::root); return 0; }