結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-21 11:31:11 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 518 bytes |
| コンパイル時間 | 1,193 ms |
| コンパイル使用メモリ | 64,956 KB |
| 最終ジャッジ日時 | 2024-11-14 20:23:35 |
| 合計ジャッジ時間 | 1,622 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(18, 53) Error: 'j' is of type <lent int> which cannot be captured as it would violate memory safety, declared here: /home/judge/data/code/Main.nim(17, 9); using '-d:nimNoLentIterators' helps in some cases. Consider using a <ref lent int> which can be captured.
ソースコード
import sequtils, strutils
var
s = readLine(stdin)
c:seq[int] = @[]
w:seq[int] = @[]
res:seq[int] = @[]
proc main():int =
for i,v in s:
if v == 'c':
c.add(i)
elif v == 'w':
w.add(i)
if c.len == 0 or w.len < 2:
return -1
for j in c:
var wNum = filter(w, proc(x:int):bool = x > j)
if wNum.len < 2: continue
res.add(wNum[1] - j + 1)
if res.len == 0:
return -1
else:
return min(res)
echo main()