Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #13174623

Source Code Expand

Copy
```gets

ll = r_ = _l = rr = 0 # (ll, r_)(_l, rr)
r_min1 = r_min2 = l_min1 = l_min2 = [1000001,0]
\$<.each{|s|
z = s.size-1 # -1 for "\n"
r = l = i = 0
r = i = s.index(?(,0)||z if s[0] == ?)
until i == z
j = s.index(?),i)||z # i(((j
k = s.index(?(,j)||z # j)))k

cr = k-j-j+i-l
if 0<cr
r += cr
l = 0
else
l = -cr
end

i = k
end
# r), (l

if r == 0
ll += l
elsif l == 0
rr += r
else
r_ += r
_l += l
if r < r_min2[0]
if r < r_min1[0]
r_min2 = r_min1
r_min1 = [r,\$.]
else
r_min2 = [r,\$.]
end
end
if l < l_min2[0]
if l < l_min1[0]
l_min2 = l_min1
l_min1 = [l,\$.]
else
l_min2 = [l,\$.]
end
end
end
}

if ll+_l == r_+rr and ll>=r_ && _l<=rr || [r_min1,r_min2].product([l_min1,l_min2]).any?{|(r,ri),(l,li)| ri!=li && ll>=r && l<=rr }
puts'Yes'
else
puts'No'
end
```

#### Submission Info

Submission Time 2020-05-13 18:27:47+0900 F - Bracket Sequencing ds14050 Ruby (2.7.1) 600 898 Byte AC 533 ms 14308 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01, sample_02, sample_03, sample_04
All 600 / 600 random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, random_11, random_12, random_13, random_21, random_22, random_23, random_31, random_32, random_33, random_41, random_42, random_43, random_51, random_52, random_53, random_61, random_62, random_63, sample_01, sample_02, sample_03, sample_04
Case Name Status Exec Time Memory
random_01 231 ms 14260 KB
random_02 460 ms 14172 KB
random_03 281 ms 14192 KB
random_04 533 ms 14136 KB
random_05 525 ms 14100 KB
random_06 300 ms 14152 KB
random_07 143 ms 14128 KB
random_08 123 ms 14136 KB
random_09 116 ms 14200 KB
random_10 298 ms 14160 KB
random_11 52 ms 14028 KB
random_12 55 ms 14064 KB
random_13 52 ms 14220 KB
random_21 54 ms 14092 KB
random_22 52 ms 14156 KB
random_23 58 ms 14084 KB
random_31 53 ms 14072 KB
random_32 55 ms 14196 KB
random_33 56 ms 14192 KB
random_41 52 ms 14048 KB
random_42 54 ms 14288 KB
random_43 52 ms 14308 KB
random_51 53 ms 14072 KB
random_52 51 ms 14124 KB
random_53 53 ms 14280 KB
random_61 197 ms 14280 KB
random_62 235 ms 14172 KB
random_63 304 ms 14052 KB
sample_01 53 ms 14264 KB
sample_02 54 ms 14208 KB
sample_03 56 ms 14136 KB
sample_04 51 ms 14020 KB