結果
問題 | No.38 赤青白ブロック |
ユーザー |
![]() |
提出日時 | 2015-02-21 20:51:40 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 79 ms / 5,000 ms |
コード長 | 578 bytes |
コンパイル時間 | 319 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 7,424 KB |
最終ジャッジ日時 | 2024-12-23 12:42:53 |
合計ジャッジ時間 | 1,953 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
def judge(S): global Kr global Kb for i in range(len(S)): if S[i]=='R' and i+Kr < len(S) and S[i+Kr] == 'R': return False if S[i]=='B' and i+Kb < len(S) and S[i+Kb] =='B': return False return True def rec(S): global ans if S in used or len(S) < ans: return used.add(S) if judge(S): ans= max(ans,len(S)) return for i in range(len(S)): if S[i]!='W': rec(S[:i]+S[i+1:]) Kr,Kb=map(int,raw_input().split()) S=raw_input() ans =0 used = set([]) rec(S) print ans