結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー maguroflymagurofly
提出日時 2020-09-11 22:17:42
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 869 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 11,184 KB
実行使用メモリ 16,968 KB
最終ジャッジ日時 2023-08-27 15:02:15
合計ジャッジ時間 5,422 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 81 ms
15,112 KB
testcase_02 AC 80 ms
15,136 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 101 ms
16,104 KB
testcase_16 AC 101 ms
16,064 KB
testcase_17 AC 111 ms
16,408 KB
testcase_18 AC 124 ms
16,960 KB
testcase_19 AC 96 ms
15,848 KB
testcase_20 AC 87 ms
15,524 KB
testcase_21 AC 101 ms
16,152 KB
testcase_22 AC 94 ms
15,804 KB
testcase_23 AC 97 ms
15,712 KB
testcase_24 AC 95 ms
15,680 KB
testcase_25 AC 109 ms
16,260 KB
testcase_26 AC 92 ms
16,108 KB
testcase_27 AC 80 ms
15,140 KB
testcase_28 AC 108 ms
16,520 KB
testcase_29 AC 92 ms
15,884 KB
testcase_30 AC 100 ms
16,144 KB
testcase_31 AC 113 ms
16,708 KB
testcase_32 AC 110 ms
16,936 KB
testcase_33 AC 96 ms
15,708 KB
testcase_34 AC 116 ms
16,968 KB
testcase_35 AC 127 ms
16,864 KB
testcase_36 AC 96 ms
15,664 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
s = gets.split.map &:to_i
t = gets.split.map &:to_i
a = Array.new(n) {[nil] * n}

sum = 0
row1 = [false] * n
col1 = [false] * n
row0 = n

s.each_with_index do |x, i|
    if x == 0
        n.times { |j| a[i][j] = 0 }
    elsif x == 2
        sum += n
        row0 -= 1
        row1[i] = true
        n.times do |j|
            col1[j] = true
            a[i][j] = 1
        end
    end
end
t.each_with_index do |x, j|
    if x == 0
        n.times { |i| a[i][j] = 0 }
    elsif x == 2
        sum += row0
        col1[j] = true
        n.times do |i|
            row1[i] = true
            a[i][j] = 1
        end
    end
end
n.times do |i|
    n.times do |j|
        if !a[i][j]
            if !row1[i] or !col1[j]
                row1[i] = col1[j] = true
                a[i][j] = 1
                sum += 1
            end
        end
    end
end

p sum
0