結果
| 問題 | No.5002 stick xor | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-05-26 01:44:12 | 
| 言語 | Ruby (3.4.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 30 ms / 1,000 ms | 
| コード長 | 830 bytes | 
| コンパイル時間 | 1,839 ms | 
| 実行使用メモリ | 4,440 KB | 
| スコア | 283 | 
| 最終ジャッジ日時 | 2018-05-26 01:44:17 | 
| ジャッジサーバーID (参考情報) | judge7 / | 
| 純コード判定しない問題か言語 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 32 | 
コンパイルメッセージ
Syntax OK
ソースコード
N, K = gets.split.map &:to_i
L = gets.split.map &:to_i
board = $<.map{|s|
  s.chomp.chars
}
rows = board.map{|a|
  (a*"").to_i 2
}
cols = board.transpose.map{|a|
  (a*"").to_i 2
}
def count_white(a)
  a.map{|b|
    ("%b"%b).count ?0
  }.sum
end
FirstScore = count_white(rows)
def calc_score(a)
  count_white(a) - FirstScore
end
L.each{|l|
  n = 1
  (l - 1).times{ n = (n << 1) | 1  }
  start = rand(1..N-l+1)
  n << (N - start)
  horizonalp = rand(2) > 0
  idx = rand(N)
  m = 1 << (N - idx - 1)
  if horizonalp
    rows[idx] ^= n
    cols.map!{|a| a ^= m }
  else
    cols[idx] ^= n
    rows.map!{|a| a ^= m }
  end
  a = b = c = d = 0
  if horizonalp
    a = c = idx + 1
    b = start
    d = start + l - 1
  else
    b = d = idx + 1
    a = start
    c = start + l - 1
  end
  puts [a, b, c, d] * " "
}
# p calc_score(rows)
            
            
            
        