結果
問題 |
No.1021 Children in Classrooms
|
ユーザー |
![]() |
提出日時 | 2020-04-10 22:07:33 |
言語 | Nim (2.2.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 917 bytes |
コンパイル時間 | 4,270 ms |
コンパイル使用メモリ | 66,304 KB |
実行使用メモリ | 14,720 KB |
最終ジャッジ日時 | 2024-09-15 20:30:11 |
合計ジャッジ時間 | 5,890 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 1 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'algorithm' [UnusedImport] /home/judge/data/code/Main.nim(1, 19) Warning: imported and not used: 'math' [UnusedImport] /home/judge/data/code/Main.nim(1, 45) Warning: imported and not used: 'macros' [UnusedImport]
ソースコード
import algorithm, math, sequtils, strutils, macros let read* = iterator: string {.closure.} = while true: (for s in stdin.readLine.split: yield s) template input*(T: static[typedesc]): untyped = when T is int: read().parseInt elif T is float: read().parseFloat elif T is string: read() let N, M = input(int) var A = @[0] & newSeqWith(N, input(int)) let S = input(string) var lmax, rmax, now = 0 for c in S: case c of 'L': if now > -(N - 1): now -= 1 lmax = max(lmax, -now) of 'R': if now < N - 1: now += 1 rmax = max(rmax, now) else: discard for i in 1 .. lmax: A[i + 1] += A[i] A[i] = 0 for i in 1 .. rmax: A[^(i + 1)] += A[^i] A[^i] = 0 if now == 0: echo A[1 .. N].mapIt($it).join(" ") elif now < 0: let L = -now echo (A[L + 1 .. N] & 0.repeat(L)).mapIt($it).join(" ") else: let R = now echo (0.repeat(R) & A[1 .. ^(R + 1)]).mapIt($it).join(" ")