Submission #1907644


Source Code Expand

Copy
lines = $stdin.read
array = lines.split("\n")
S = array[0]
N = S.length

ans = [N-1]

for i in 1...N
  first, second = S[i-1], S[i]
  if first != second
    ans << [i-1, N-i-1].max
  end
  # p ans
end

puts (ans.min).to_i + 1

Submission Info

Submission Time
Task D - Wide Flip
User hiroyuking
Language Ruby (2.3.3)
Score 500
Code Size 240 Byte
Status
Exec Time 64 ms
Memory 4220 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 500 / 500 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, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 63 ms 2428 KB
02.txt 63 ms 2428 KB
03.txt 64 ms 2428 KB
04.txt 63 ms 2428 KB
05.txt 59 ms 2300 KB
06.txt 49 ms 2172 KB
07.txt 43 ms 2044 KB
08.txt 47 ms 2172 KB
09.txt 58 ms 2300 KB
10.txt 58 ms 2300 KB
11.txt 57 ms 2300 KB
12.txt 48 ms 4220 KB
13.txt 54 ms 2300 KB
14.txt 62 ms 2428 KB
15.txt 62 ms 2428 KB
16.txt 58 ms 2300 KB
17.txt 41 ms 1916 KB
18.txt 41 ms 1916 KB
19.txt 41 ms 1916 KB
20.txt 41 ms 1916 KB
21.txt 7 ms 1788 KB
22.txt 7 ms 1788 KB
23.txt 7 ms 1788 KB
24.txt 7 ms 1788 KB
25.txt 7 ms 1788 KB
26.txt 7 ms 1788 KB
27.txt 7 ms 1788 KB
s1.txt 7 ms 1788 KB
s2.txt 7 ms 1788 KB
s3.txt 7 ms 1788 KB