結果

問題 No.38 赤青白ブロック
ユーザー 6soukiti296soukiti29
提出日時 2017-07-27 23:01:48
言語 Nim
(2.0.2)
結果
AC  
実行時間 459 ms / 5,000 ms
コード長 1,013 bytes
コンパイル時間 3,230 ms
コンパイル使用メモリ 68,884 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 13:39:31
合計ジャッジ時間 16,278 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 438 ms
4,380 KB
testcase_01 AC 410 ms
4,380 KB
testcase_02 AC 398 ms
4,380 KB
testcase_03 AC 421 ms
4,376 KB
testcase_04 AC 410 ms
4,380 KB
testcase_05 AC 459 ms
4,380 KB
testcase_06 AC 404 ms
4,376 KB
testcase_07 AC 408 ms
4,380 KB
testcase_08 AC 453 ms
4,376 KB
testcase_09 AC 416 ms
4,380 KB
testcase_10 AC 443 ms
4,376 KB
testcase_11 AC 448 ms
4,376 KB
testcase_12 AC 411 ms
4,380 KB
testcase_13 AC 451 ms
4,380 KB
testcase_14 AC 425 ms
4,376 KB
testcase_15 AC 450 ms
4,380 KB
testcase_16 AC 373 ms
4,380 KB
testcase_17 AC 397 ms
4,380 KB
testcase_18 AC 446 ms
4,376 KB
testcase_19 AC 415 ms
4,376 KB
testcase_20 AC 419 ms
4,380 KB
testcase_21 AC 397 ms
4,380 KB
testcase_22 AC 416 ms
4,384 KB
testcase_23 AC 439 ms
4,380 KB
testcase_24 AC 398 ms
4,376 KB
testcase_25 AC 427 ms
4,380 KB
testcase_26 AC 424 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'math' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,math

proc matchstr(s : string,c : char, index : int): bool =
    if index < 0:
        return false
    if index > s.high:
        return false
    if s[index] == c:
        return true
    else:
        return false


var
    Kr,Kb : int
    S : string
    ans = 0
(Kr,Kb) = stdin.readline.split.map(parseInt)
S = stdin.readline

for i in 1..<(1 shl 20):
    var
        j = i
        ns = ""
        flag = true
    for s in S:
        if s == 'W':
            ns &= "W"
        else:
            if j mod 2 == 1:
                ns &= s
            j = j shr 1
    for index,s in ns:
        if s == 'W':
            continue
        elif (s == 'R' and
            (matchstr(ns,s,index + Kr) or
            matchstr(ns,s,index - Kr))):
            flag = false
            break
        elif (s == 'B' and
            (matchstr(ns,s,index + Kb) or 
            matchstr(ns,s,index - Kb))):
            flag = false
            break
    if flag:
        ans = max(ans,ns.len)
echo ans
0