Submission #2416624
Source Code Expand
def result score = 0 2.times do |i| 3.times do |j| score += @b[i][j] if @board[i][j] == @board[i+1][j] score += @c[j][i] if @board[j][i] == @board[j][i+1] end end score end def dfs(cnt) return result() if cnt == 9 if cnt.even? mx = 0 3.times do |i| 3.times do |j| if @board[i][j] == -1 @board[i][j] = 1 mx = [ mx, dfs(cnt+1) ].max @board[i][j] = -1 end end end return mx else mn = Float::INFINITY 3.times do |i| 3.times do |j| if @board[i][j] == -1 @board[i][j] = 0 mn = [ mn, dfs(cnt+1) ].min @board[i][j] = -1 end end end return mn end end @b = Array.new(2) { gets.split.map(&:to_i) } @c = Array.new(3) { gets.split.map(&:to_i) } @board = Array.new(3) { Array.new(3, -1) } score = dfs(0) puts score puts @b.flatten.inject(&:+) + @c.flatten.inject(&:+) - score
Submission Info
Submission Time | |
---|---|
Task | C - 双子と○×ゲーム |
User | tfnw315 |
Language | Ruby (2.3.3) |
Score | 0 |
Code Size | 1000 Byte |
Status | TLE |
Exec Time | 2107 ms |
Memory | 1788 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt |
All | sample-01.txt, sample-02.txt, test-01.txt, test-02.txt, test-03.txt, test-04.txt, test-05.txt, test-06.txt, test-07.txt, test-08.txt, test-09.txt, test-10.txt, test-11.txt, test-12.txt, test-13.txt, test-14.txt, test-15.txt, test-16.txt, test-17.txt, test-18.txt, test-19.txt, test-20.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample-01.txt | TLE | 2107 ms | 1788 KB |
sample-02.txt | TLE | 2107 ms | 1788 KB |
test-01.txt | TLE | 2090 ms | 1788 KB |
test-02.txt | TLE | 2086 ms | 1788 KB |
test-03.txt | TLE | 2107 ms | 1788 KB |
test-04.txt | TLE | 2079 ms | 1788 KB |
test-05.txt | TLE | 2092 ms | 1788 KB |
test-06.txt | TLE | 2107 ms | 1788 KB |
test-07.txt | TLE | 2086 ms | 1788 KB |
test-08.txt | TLE | 2054 ms | 1788 KB |
test-09.txt | TLE | 2107 ms | 1788 KB |
test-10.txt | TLE | 2090 ms | 1788 KB |
test-11.txt | TLE | 2042 ms | 1788 KB |
test-12.txt | TLE | 2107 ms | 1788 KB |
test-13.txt | TLE | 2069 ms | 1788 KB |
test-14.txt | TLE | 2087 ms | 1788 KB |
test-15.txt | TLE | 2084 ms | 1788 KB |
test-16.txt | TLE | 2107 ms | 1788 KB |
test-17.txt | TLE | 2047 ms | 1788 KB |
test-18.txt | TLE | 2078 ms | 1788 KB |
test-19.txt | TLE | 2035 ms | 1788 KB |
test-20.txt | TLE | 2107 ms | 1788 KB |