Submission #2120339


Source Code Expand

require 'pp'
N = gets.to_i
CARDS = readlines.map{|l| l.split.map(&:to_i)} #.with_index{|l, i| l.split.map(&:to_i) + [i]}

def rot(ary, n)
  ary[n..-1] + ary[0...n]
end

INDEX = Hash.new{|h, k| h[k] = []}
#INDEX = Hash.new{|h, k|
#  h[k] = Hash.new{|h, k|
#    h[k] = Hash.new{|h, k|
#      h[k] = []
#    }
#  }
#}
CARDS.each.with_index do |cols, n|
  4.times do |i|
    INDEX[rot(cols, i)] << n
  end
end

ans = 0
for i in 0..(N-2)
  for j in (i+1)..(N-1)
    3.times do |k|
      a, b, c, d = rot(CARDS[i], k)
      3.times do |l|
        e, f, g, h = rot(CARDS[j], l)

        #    a--b\
        #    |\d--c
        #    e | h|
        #     \f--g

        cands = [
          INDEX[[a,d,f,e]],
          INDEX[[d,c,g,f]],
          INDEX[[c,b,h,g]],
          INDEX[[b,a,e,h]],
        ]
        #p ijk: [i+1, j+1], abcd: [a, b, c, d], efgh: [e,f,g,h], cands: cands
        ans += cands.inject(:product).map(&:flatten).select{|x| x.uniq.size == 4}.count
      end
    end
  end
end

p ans / 6 #TODO

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User yhara
Language Ruby (2.3.3)
Score 0
Code Size 1052 Byte
Status RE
Exec Time 4297 ms
Memory 1270780 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
AC × 1
WA × 1
TLE × 1
AC × 4
WA × 2
TLE × 13
RE × 1
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt
Case Name Status Exec Time Memory
0_000.txt AC 14 ms 2300 KB
0_001.txt WA 37 ms 3068 KB
0_002.txt TLE 4226 ms 281788 KB
1_003.txt RE 584 ms 144380 KB
1_004.txt TLE 4281 ms 1044220 KB
1_005.txt TLE 4297 ms 1270780 KB
1_006.txt TLE 4281 ms 1024764 KB
1_007.txt TLE 4228 ms 223380 KB
1_008.txt TLE 4227 ms 188360 KB
1_009.txt TLE 4208 ms 3324 KB
1_010.txt WA 1493 ms 3056 KB
1_011.txt TLE 4208 ms 5244 KB
1_012.txt AC 59 ms 2684 KB
1_013.txt TLE 4221 ms 139796 KB
1_014.txt AC 113 ms 5500 KB
1_015.txt TLE 4224 ms 142972 KB
1_016.txt AC 2928 ms 87036 KB
1_017.txt TLE 4222 ms 142588 KB
1_018.txt TLE 4224 ms 143100 KB
1_019.txt TLE 4222 ms 142740 KB