답안 #1092114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092114 2024-09-23T08:43:09 Z juicy 돌 무게 재기 (IZhO11_stones) C++17
100 / 100
43 ms 5468 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int N = 1e5 + 5;

int n;

struct Segtree {
  int s[4 * N], lz[4 * N];

  Segtree() = default;

  void app(int id, int x) {
    s[id] += x;
    lz[id] += x;
  }

  void psh(int id) {
    if (lz[id]) {
      app(id * 2, lz[id]);
      app(id * 2 + 1, lz[id]);
      lz[id] = 0;
    }
  }

  void upd(int u, int v, int x, int id, int l, int r) {
    if (u <= l && r <= v) {
      app(id, x);
      return;
    }
    psh(id);
    int m = (l + r) / 2;
    if (u <= m) {
      upd(u, v, x, id * 2, l, m);
    }
    if (m < v) {
      upd(u, v, x, id * 2 + 1, m + 1, r);
    }
    s[id] = min(s[id * 2], s[id * 2 + 1]);
  }

  void upd(int u, int v, int x) {
    upd(u, v, x, 1, 1, n);
  }
} tree[2];

bool win(int s) {
  return tree[s].s[1] >= 0;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n;
  for (int i = 0; i < n; ++i) {
    int r, s; cin >> r >> s; --s;
    tree[s].upd(1, r, -1);
    tree[s ^ 1].upd(1, r, 1);
    cout << (win(0) ? '<' : (win(1) ? '>' : '?')) << "\n";
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 5 ms 860 KB Output is correct
11 Correct 26 ms 2908 KB Output is correct
12 Correct 43 ms 5212 KB Output is correct
13 Correct 32 ms 5456 KB Output is correct
14 Correct 33 ms 5460 KB Output is correct
15 Correct 39 ms 5460 KB Output is correct
16 Correct 33 ms 5332 KB Output is correct
17 Correct 31 ms 5468 KB Output is correct
18 Correct 39 ms 5468 KB Output is correct
19 Correct 34 ms 5468 KB Output is correct
20 Correct 32 ms 5460 KB Output is correct
21 Correct 32 ms 5460 KB Output is correct
22 Correct 35 ms 5456 KB Output is correct
23 Correct 39 ms 5460 KB Output is correct
24 Correct 35 ms 5456 KB Output is correct
25 Correct 33 ms 5460 KB Output is correct