結果
問題 | No.686 Uncertain LIS |
ユーザー | konjakujelly |
提出日時 | 2023-12-25 10:57:42 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 410 ms / 2,000 ms |
コード長 | 3,747 bytes |
コンパイル時間 | 1,817 ms |
コンパイル使用メモリ | 171,420 KB |
実行使用メモリ | 26,072 KB |
最終ジャッジ日時 | 2024-09-27 14:16:40 |
合計ジャッジ時間 | 8,399 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 13 ms
23,648 KB |
testcase_01 | AC | 13 ms
25,568 KB |
testcase_02 | AC | 14 ms
25,564 KB |
testcase_03 | AC | 14 ms
25,948 KB |
testcase_04 | AC | 14 ms
25,692 KB |
testcase_05 | AC | 14 ms
25,824 KB |
testcase_06 | AC | 13 ms
25,436 KB |
testcase_07 | AC | 12 ms
25,436 KB |
testcase_08 | AC | 14 ms
25,436 KB |
testcase_09 | AC | 355 ms
24,156 KB |
testcase_10 | AC | 340 ms
23,900 KB |
testcase_11 | AC | 223 ms
25,952 KB |
testcase_12 | AC | 23 ms
25,948 KB |
testcase_13 | AC | 122 ms
23,904 KB |
testcase_14 | AC | 76 ms
25,692 KB |
testcase_15 | AC | 53 ms
25,692 KB |
testcase_16 | AC | 118 ms
25,436 KB |
testcase_17 | AC | 400 ms
25,948 KB |
testcase_18 | AC | 402 ms
25,948 KB |
testcase_19 | AC | 410 ms
25,948 KB |
testcase_20 | AC | 155 ms
25,692 KB |
testcase_21 | AC | 152 ms
25,436 KB |
testcase_22 | AC | 54 ms
25,564 KB |
testcase_23 | AC | 51 ms
23,516 KB |
testcase_24 | AC | 205 ms
25,820 KB |
testcase_25 | AC | 210 ms
25,816 KB |
testcase_26 | AC | 44 ms
25,692 KB |
testcase_27 | AC | 247 ms
26,072 KB |
testcase_28 | AC | 255 ms
24,036 KB |
testcase_29 | AC | 254 ms
25,952 KB |
testcase_30 | AC | 249 ms
23,900 KB |
testcase_31 | AC | 14 ms
25,692 KB |
testcase_32 | AC | 47 ms
25,816 KB |
testcase_33 | AC | 44 ms
25,696 KB |
testcase_34 | AC | 404 ms
24,160 KB |
testcase_35 | AC | 395 ms
25,820 KB |
コンパイルメッセージ
main.cpp: In function 'int findrk(int)': main.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type] 77 | } | ^
ソースコード
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 0; char ch = getchar(); while (ch < '0' or ch > '9') f |= (ch == '-'), ch = getchar(); while (ch >= '0' and ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return f ? -x : x; } int __stk[128], __top; inline void write(int x) { if(x < 0) putchar('-'), x = -x; do { __stk[++__top] = x % 10, x /= 10; } while (x); while (__top) putchar(__stk[__top--] + '0'); } const int mod = 998244353; void Min(int &x, int y) { y < x and (x = y); } void Max(int &x, int y) { y > x and (x = y); } void inc(int &x, int y) { (x += y) >= mod and (x -= mod); } void mul(int &x, int y) { x = 1ll * x * y % mod; } int q_pow(int x, int k) { int res = 1; for (; k; k >>= 1, mul(x, x)) if (k & 1) mul(res, x); return res; } bool stmer; const int N = 1e6 + 10, M = 1e6; int n, rt, cnt, top; int t[N][2], fa[N], siz[N], s[N], tag[N], stk[N]; void update(int x) { siz[x] = siz[t[x][0]] + siz[t[x][1]] + 1; } void pushup(int x, int k) { tag[x] += k, s[x] += k; } void pushdown(int x) { pushup(t[x][0], tag[x]), pushup(t[x][1], tag[x]), tag[x] = 0; } int build(int l, int r) { if (l > r) return 0; int mid = (l + r) >> 1, x = ++cnt; t[x][0] = build(l, mid - 1), t[x][1] = build(mid + 1, r); return update(x), fa[t[x][0]] = fa[t[x][1]] = x; } int get(int x) { return t[fa[x]][1] == x; } void rotate(int x) { int f1 = fa[x], f2 = fa[f1], k = get(x); if (f2) t[f2][get(f1)] = x; fa[x] = f2; t[f1][k] = t[x][!k], fa[t[f1][k]] = f1; t[x][!k] = f1, fa[f1] = x; update(f1), update(x); } void splay(int x, int to = 0) { if (x == to) return; int p = stk[top = 1] = x; while (fa[p] ^ to) stk[++top] = p = fa[p]; while (top) pushdown(stk[top--]); for (int f; (f = fa[x]) ^ to; rotate(x)) if (fa[f] ^ to) rotate(get(x) == get(f) ? f : x); if (!to) rt = x; } int findrk(int k) { int x = rt; while (x) { pushdown(x); if (k <= siz[t[x][0]]) x = t[x][0]; else { k -= siz[t[x][0]] + 1; if (!k) return x; x = t[x][1]; } } } void split(int l, int r) { splay(findrk(l)), splay(findrk(r + 3), rt); } void out(int x) { if (!x) return; pushdown(x), out(t[x][0]); write(s[x]), putchar(' '); out(t[x][1]); } bool edmer; signed main() { // freopen("Yukicoder686.in", "r", stdin); // freopen("Yukicoder686.out", "w", stdout); cerr << "[Memory] " << (&stmer - &edmer) / 1024 / 1024 << " MB\n"; n = read(), rt = build(-1, M + 1); for (int i = 1; i <= n; i++) { int l = read(), r = read(), x, y, z; split(l, r), x = y = t[t[rt][1]][0]; while (t[y][0]) pushdown(y), y = t[y][0]; int val = s[y]; while (t[x][1]) pushdown(x), x = t[x][1]; y = fa[x], z = t[x][0], pushdown(x); t[y][y != t[rt][1]] = z, fa[z] = y, update(y); splay(z ? z : y, t[rt][1]); y = t[t[rt][1]][0], pushup(y, 1); while (t[y][0]) pushdown(y), y = t[y][0]; s[x] = val, tag[x] = 0, pushdown(y); t[x][0] = 0, siz[x] = 1, t[y][0] = x, fa[x] = y; update(y), splay(x, y = t[rt][1]); while (t[x][1]) pushdown(x), x = t[x][1]; if (s[y] < s[x]) { int lat = y; s[y]++, pushdown(y), y = t[y][1]; while (y) { lat = y, pushdown(y); if (s[y] >= s[x]) y = t[y][0]; else s[y]++, pushup(t[y][0], 1), y = t[y][1]; } splay(lat); } } int x = rt; while (t[x][1]) pushdown(x), x = t[x][1]; write(s[x]); cerr << "[Runtime] " << (double) clock() / CLOCKS_PER_SEC << " seconds\n"; return 0; }