結果
問題 | No.2611 Count 01 |
ユーザー |
|
提出日時 | 2024-01-07 11:04:00 |
言語 | Nim (2.2.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,421 bytes |
コンパイル時間 | 3,306 ms |
コンパイル使用メモリ | 66,344 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-28 03:29:55 |
合計ジャッジ時間 | 4,581 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | WA * 20 |
ソースコード
import strutils, sequtils, deques type stdinReader = object buf: Deque[string] func newStdinReader(): stdinReader = result = stdinReader(buf: initDeque[string]()) proc readString(sr: var stdinReader): string = if sr.buf.len == 0: sr.buf = stdin.readLine.split.toDeque sr.buf.popFirst proc readInt(sr: var stdinReader): int = readString(sr).parseInt var reader = newStdinReader() let (n, q) = (reader.readInt, reader.readInt) let s = reader.readString var sSeq = s.mapIt(int(it) - int('0')) const MOD = 998244353 if q > 10000: quit(0) for _ in 0..<q: let t = reader.readInt if t == 1: let i = reader.readInt - 1 sSeq[i] = 1 - sSeq[i] else: let (l, r) = (reader.readInt - 1, reader.readInt - 1) var count = 1 a = 0 b = 0 x = 0 ans = 0 for i in sSeq[l..r]: if i == 0: a += count if a >= MOD: a = a - MOD x += b if x >= MOD: x = x - MOD else: b += count if b >= MOD: b = b - MOD x += a if x >= MOD: x = x - MOD count += 1 ans += x if ans >= MOD: ans = ans - MOD echo ans