結果

問題 No.1020 Reverse
ユーザー nadeshinonadeshino
提出日時 2020-04-10 21:48:51
言語 Nim
(2.0.2)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 4,977 ms
コンパイル使用メモリ 69,092 KB
実行使用メモリ 4,816 KB
最終ジャッジ日時 2023-10-14 00:15:59
合計ジャッジ時間 6,328 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 5 ms
4,352 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 4 ms
4,352 KB
testcase_10 AC 6 ms
4,496 KB
testcase_11 AC 9 ms
4,808 KB
testcase_12 AC 4 ms
4,648 KB
testcase_13 AC 4 ms
4,584 KB
testcase_14 AC 9 ms
4,776 KB
testcase_15 AC 11 ms
4,816 KB
testcase_16 AC 11 ms
4,708 KB
testcase_17 AC 4 ms
4,476 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 45) Warning: imported and not used: 'macros' [UnusedImport]
/home/judge/data/code/Main.nim(1, 19) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 25) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

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, K = input(int)
let S = "#" & input(string)
if K < N and (N - K) mod 2 == 1:
  echo S[K .. N] & S[1 .. K - 1]
elif K < N and (N - K) mod 2 == 0:
  echo S[K .. N] & S[1 .. K - 1].reversed.join("")
else:
  echo S[1 .. N].reversed.join("")
0