Submission #2821831
Source Code Expand
N = gets.to_i S = gets.chomp.split(//) animals = [ ['S', 'S'], ['S', 'W'], ['W', 'S'], ['W', 'W'] ] paths = [] animals.each do |animal| path = animal.dup S.each_with_index do |c, i| next if i == 0 || i == S.length-1 if path[i] == 'S' if c == 'o' path << (path[i-1] == 'S' ? 'S' : 'W') else path << (path[i-1] == 'S' ? 'W' : 'S') end else if c == 'o' path << (path[i-1] == 'S' ? 'W' : 'S') else path << (path[i-1] == 'S' ? 'S' : 'W') end end end paths << path end paths.each do |path| result = true S.each_with_index do |s, i| if path[i] == 'S' if s == 'o' if path[i-1] != (path[i+1] || path[0]) result = false break end else if path[i-1] == (path[i+1] || path[0]) result = false break end end else if s == 'x' if path[i-1] != (path[i+1] || path[0]) result = false break end else if path[i-1] == (path[i+1] || path[0]) result = false break end end end end if result puts(path.join) exit end end puts('-1')
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | sada4 |
Language | Ruby (2.3.3) |
Score | 500 |
Code Size | 1283 Byte |
Status | AC |
Exec Time | 384 ms |
Memory | 45876 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 7 ms | 1788 KB |
00_example_02.txt | AC | 7 ms | 1788 KB |
00_example_03.txt | AC | 7 ms | 1788 KB |
01.txt | AC | 225 ms | 26548 KB |
02.txt | AC | 149 ms | 18552 KB |
03.txt | AC | 15 ms | 2556 KB |
04.txt | AC | 7 ms | 1788 KB |
05.txt | AC | 337 ms | 40440 KB |
06.txt | AC | 304 ms | 33912 KB |
07.txt | AC | 53 ms | 7832 KB |
08.txt | AC | 57 ms | 9084 KB |
09.txt | AC | 21 ms | 3452 KB |
10.txt | AC | 57 ms | 9212 KB |
11.txt | AC | 382 ms | 45876 KB |
12.txt | AC | 383 ms | 45876 KB |
13.txt | AC | 384 ms | 45876 KB |