Submission #169354


Source Code Expand

Copy
w,h = gets.split.map(&:to_i)
n = gets.to_i
x = Array.new(n)
y = Array.new(n)
n.times do |i|
    x[i], y[i] = gets.split.map(&:to_i).map{|a| a-1}
end
max = 0
(0...n).to_a.permutation(n).each do |p|
    f = Array.new(w).map{Array.new(h,true)}
    sum = 0
    for i in 0...n
        cx = x[p[i]]
        cy = y[p[i]]
        f[cx][cy] = false
        sum += 1
        cx -= 1
        #left
        while cx >=0 && f[cx][cy]==true
            f[cx][cy] = false
            sum += 1
            cx -= 1
        end
        #right
        cx = x[p[i]] + 1
        cy = y[p[i]]
        while cx < w && f[cx][cy]==true
            f[cx][cy] = false
            sum += 1
            cx += 1
        end
        #up
        cx = x[p[i]]
        cy = y[p[i]] + 1
        while cy < h && f[cx][cy]==true
            f[cx][cy] = false
            sum += 1
            cy += 1
        end
        #down
        cx = x[p[i]]
        cy = y[p[i]] - 1
        while cy >= 0 && f[cx][cy]==true
            f[cx][cy] = false
            sum += 1
            cy -= 1
        end
    end
    max = max<sum ? sum : max
end
puts max


Submission Info

Submission Time
Task D - 金塊ゲーム
User takuk
Language Ruby (1.9.3)
Score 0
Code Size 1165 Byte
Status TLE
Exec Time 4440 ms
Memory 333308 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 0 / 80 0 / 19 0 / 1
Status
AC × 3
AC × 19
TLE × 6
AC × 19
TLE × 31
AC × 19
TLE × 56
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt
Subtask2 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt, subtask2_21.txt, subtask2_22.txt, subtask2_23.txt, subtask2_24.txt, subtask2_25.txt
Subtask3 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt, subtask2_21.txt, subtask2_22.txt, subtask2_23.txt, subtask2_24.txt, subtask2_25.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt, subtask3_13.txt, subtask3_14.txt, subtask3_15.txt, subtask3_16.txt, subtask3_17.txt, subtask3_18.txt, subtask3_19.txt, subtask3_20.txt, subtask3_21.txt, subtask3_22.txt, subtask3_23.txt, subtask3_24.txt, subtask3_25.txt
Case Name Status Exec Time Memory
sample_01.txt AC 58 ms 4256 KB
sample_02.txt AC 56 ms 4260 KB
sample_03.txt AC 1544 ms 4760 KB
subtask1_01.txt AC 58 ms 4344 KB
subtask1_02.txt AC 56 ms 4256 KB
subtask1_03.txt AC 1133 ms 4772 KB
subtask1_04.txt AC 2462 ms 5412 KB
subtask1_05.txt AC 57 ms 4264 KB
subtask1_06.txt AC 59 ms 4256 KB
subtask1_07.txt AC 65 ms 4776 KB
subtask1_08.txt AC 57 ms 4256 KB
subtask1_09.txt AC 94 ms 8612 KB
subtask1_10.txt AC 55 ms 4260 KB
subtask1_11.txt AC 59 ms 5404 KB
subtask1_12.txt AC 72 ms 4892 KB
subtask1_13.txt AC 139 ms 4772 KB
subtask1_14.txt AC 236 ms 8664 KB
subtask1_15.txt TLE 4033 ms 8680 KB
subtask1_16.txt AC 3244 ms 6020 KB
subtask1_17.txt TLE 4031 ms 5640 KB
subtask1_18.txt AC 1722 ms 5028 KB
subtask1_19.txt AC 1095 ms 4640 KB
subtask1_20.txt AC 1107 ms 4636 KB
subtask1_21.txt TLE 4033 ms 6512 KB
subtask1_22.txt TLE 4037 ms 8268 KB
subtask1_23.txt AC 2176 ms 5656 KB
subtask1_24.txt TLE 4034 ms 8428 KB
subtask1_25.txt TLE 4035 ms 8796 KB
subtask2_01.txt TLE 4034 ms 5572 KB
subtask2_02.txt TLE 4033 ms 5792 KB
subtask2_03.txt TLE 4037 ms 7500 KB
subtask2_04.txt TLE 4033 ms 8676 KB
subtask2_05.txt TLE 4032 ms 7424 KB
subtask2_06.txt TLE 4033 ms 7068 KB
subtask2_07.txt TLE 4033 ms 6240 KB
subtask2_08.txt TLE 4032 ms 6208 KB
subtask2_09.txt TLE 4034 ms 8384 KB
subtask2_10.txt TLE 4035 ms 8524 KB
subtask2_11.txt TLE 4034 ms 6440 KB
subtask2_12.txt TLE 4036 ms 8372 KB
subtask2_13.txt TLE 4034 ms 8772 KB
subtask2_14.txt TLE 4035 ms 8688 KB
subtask2_15.txt TLE 4035 ms 8700 KB
subtask2_16.txt TLE 4033 ms 6536 KB
subtask2_17.txt TLE 4035 ms 6432 KB
subtask2_18.txt TLE 4036 ms 6932 KB
subtask2_19.txt TLE 4033 ms 6472 KB
subtask2_20.txt TLE 4033 ms 7392 KB
subtask2_21.txt TLE 4034 ms 7424 KB
subtask2_22.txt TLE 4036 ms 7972 KB
subtask2_23.txt TLE 4035 ms 7940 KB
subtask2_24.txt TLE 4035 ms 8552 KB
subtask2_25.txt TLE 4035 ms 8456 KB
subtask3_01.txt TLE 4380 ms 332548 KB
subtask3_02.txt TLE 4402 ms 333180 KB
subtask3_03.txt TLE 4135 ms 121520 KB
subtask3_04.txt TLE 4036 ms 12368 KB
subtask3_05.txt TLE 4035 ms 12944 KB
subtask3_06.txt TLE 4376 ms 332400 KB
subtask3_07.txt TLE 4400 ms 332540 KB
subtask3_08.txt TLE 4358 ms 310824 KB
subtask3_09.txt TLE 4366 ms 332536 KB
subtask3_10.txt TLE 4316 ms 316960 KB
subtask3_11.txt TLE 4376 ms 332536 KB
subtask3_12.txt TLE 4091 ms 126112 KB
subtask3_13.txt TLE 4381 ms 332508 KB
subtask3_14.txt TLE 4419 ms 324004 KB
subtask3_15.txt TLE 4400 ms 332528 KB
subtask3_16.txt TLE 4419 ms 322804 KB
subtask3_17.txt TLE 4440 ms 332528 KB
subtask3_18.txt TLE 4401 ms 332540 KB
subtask3_19.txt TLE 4378 ms 332532 KB
subtask3_20.txt TLE 4275 ms 277928 KB
subtask3_21.txt TLE 4328 ms 331260 KB
subtask3_22.txt TLE 4419 ms 333308 KB
subtask3_23.txt TLE 4376 ms 332540 KB
subtask3_24.txt TLE 4229 ms 316148 KB
subtask3_25.txt TLE 4381 ms 332544 KB