結果
問題 | No.5002 stick xor |
ユーザー |
|
提出日時 | 2018-05-26 03:34:14 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,667 bytes |
コンパイル時間 | 40,365 ms |
スコア | 0 |
最終ジャッジ日時 | 2018-05-26 03:34:56 |
ジャッジサーバーID (参考情報) |
judge7 / |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 32 |
コンパイルメッセージ
Main.rb:53: warning: assigned but unused variable - size Syntax OK
ソースコード
N, K = gets.split.map &:to_iL = gets.split.map &:to_iLI = L.map.with_index{|l, i| [l, i]}.sort_by{|l, i| -l}board = $<.map{|s|s.chomp.chars}$rows = board.map{|a| a*"" }$cols = board.transpose.map{|a| a*"" }def count_white$rows.map{|a|N - a.count(?1)}.sumendFirstScore = count_whitedef calc_scorecount_white - FirstScoreend# p FirstScore# p calc_score()$memo = []def update_memo(len)max = 0$rows.map.with_index{|s, i|cusum = [sum = 0] + s.chars.map{|c|sum += c == ?1 ? 1 : 0}(0..N-len).each{|j|if cusum[j+len] - cusum[j] > maxmax = cusum[j+len] - cusum[j]$memo = [:r, max, i, j]end}}$cols.map.with_index{|s, i|cusum = [sum = 0] + s.chars.map{|c|sum += c == ?1 ? 1 : 0}(0..N-len).each{|j|if cusum[j+len] - cusum[j] > maxmax = cusum[j+len] - cusum[j]$memo = [:c, max, i, j]end}}endans = []LI.each{|l, i|update_memo(l)sym, size, idx, pos = $memoif sym.nil?sym = [:r, :c].sampleidx = rand(N)pos = rand(N)endpos = [N - l, pos].minif sym == :rt = $rows[idx][pos, l]$rows[idx][pos, l] = t.tr("01", "10")(pos...pos+l).each{|j|c = $cols[j][idx]$cols[j][idx] = c == ?1 ? ?0 : ?1}a = c = idx + 1b = pos + 1d = pos + lelset = $cols[idx][pos, l]$cols[idx][pos, l] = t.tr("01", "10")(pos...pos+l).each{|j|c = $rows[j][idx]$rows[j][idx] = c == ?1 ? ?0 : ?1}b = d = idx + 1a = pos + 1c = pos + lendans[i] = [a, b, c, d]}ans.each{|a|puts a * " "}# p calc_score()