結果
| 問題 | No.1376 Simple LPS Problem |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-06-15 06:30:38 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 2,000 ms |
| コード長 | 605 bytes |
| コンパイル時間 | 265 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2024-10-03 12:52:40 |
| 合計ジャッジ時間 | 7,450 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 60 |
コンパイルメッセージ
Main.rb:33: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:36: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
N, K = gets.split.map(&:to_i)
def f
0.upto(2 ** N - 1) do |mask|
str = mask.to_s(2).rjust(N, '0')
ok = true
found = false
N.downto(K) do |k|
0.upto(N - k) do |i|
s = str[i...i + k]
if s == s.reverse
if k > K
ok = false
else
found = true
end
end
end
end
return str if ok && found
end
false
end
if N <= 9
if res = f
puts res
else
puts -1
end
elsif K <= 3
puts -1
else
tmp = '010011'
len = 6
str = ('1' * K) + tmp * Rational(N, len).ceil
puts str[0...N]
end
siman