結果
問題 | No.2080 Simple Nim Query |
ユーザー | 👑 tamato |
提出日時 | 2022-09-25 21:17:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 311 ms / 3,000 ms |
コード長 | 1,753 bytes |
コンパイル時間 | 473 ms |
コンパイル使用メモリ | 87,244 KB |
実行使用メモリ | 106,140 KB |
最終ジャッジ日時 | 2023-09-03 02:47:53 |
合計ジャッジ時間 | 3,890 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 66 ms
71,476 KB |
testcase_01 | AC | 65 ms
71,456 KB |
testcase_02 | AC | 63 ms
71,484 KB |
testcase_03 | AC | 212 ms
79,624 KB |
testcase_04 | AC | 184 ms
79,352 KB |
testcase_05 | AC | 299 ms
102,272 KB |
testcase_06 | AC | 286 ms
105,948 KB |
testcase_07 | AC | 291 ms
105,972 KB |
testcase_08 | AC | 310 ms
105,868 KB |
testcase_09 | AC | 311 ms
106,044 KB |
testcase_10 | AC | 182 ms
106,140 KB |
ソースコード
mod = 998244353 def main(): import sys input = sys.stdin.readline class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, w): if w <= 0: return 0 x = 0 k = 1 << (self.size.bit_length() - 1) while k: if x + k <= self.size and self.tree[x + k] < w: w -= self.tree[x + k] x += k k >>= 1 return x + 1 N, Q = map(int, input().split()) A = list(map(int, input().split())) bit = Bit(N) for i, a in enumerate(A): if a != 1: bit.add(i+1, 1) for _ in range(Q): t, x, y = map(int, input().split()) if t == 1: if A[x - 1] == 1 and y != 1: bit.add(x, 1) elif A[x - 1] != 1 and y == 1: bit.add(x, -1) A[x - 1] = y else: if x == y: print("F") else: k = bit.sum(y) j = bit.lower_bound(k) if j < x: if (y - x) & 1: print("S") else: print("F") else: if (y - j) & 1: print("S") else: print("F") if __name__ == '__main__': main()