結果
問題 | No.2611 Count 01 |
ユーザー |
|
提出日時 | 2024-01-07 10:48:54 |
言語 | Nim (2.2.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,394 bytes |
コンパイル時間 | 3,878 ms |
コンパイル使用メモリ | 66,180 KB |
実行使用メモリ | 13,084 KB |
最終ジャッジ日時 | 2024-09-28 03:29:40 |
合計ジャッジ時間 | 11,321 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | TLE * 1 -- * 19 |
ソースコード
import strutils, sequtils, dequestype stdinReader = objectbuf: 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.toDequesr.buf.popFirstproc readInt(sr: var stdinReader): int =readString(sr).parseIntvar reader = newStdinReader()let (n, q) = (reader.readInt, reader.readInt)let s = reader.readStringvar sSeq = s.mapIt(int(it) - int('0'))const MOD = 998244353for _ in 0..<q:let t = reader.readIntif t == 1:let i = reader.readInt - 1sSeq[i] = 1 - sSeq[i]else:let (l, r) = (reader.readInt - 1, reader.readInt - 1)varcount = 1a = 0b = 0x = 0ans = 0for i in sSeq[l..r]:if i == 0:a += countif a >= MOD:a = a - MODx += bif x >= MOD:x = x - MODelse:b += countif b >= MOD:b = b - MODx += aif x >= MOD:x = x - MODcount += 1ans += xif ans >= MOD:ans = ans - MODecho ans