def je_dobry return false if $N == 0 return false if $N%2 != 0 return false if $sucet != 0 teraz = 0 $N.times{ |i| teraz += ($stav[i] ? 1 : -1); return false if teraz < 0 } return true end $sucet = 0 print "Zadaj N: "; $N = readline.to_i print "Zadaj M: "; $M = readline.to_i $stav = [] print "Zadaj str:"; line = (readline())[0..$N] $N.times{ |i| $stav << (line[i,1] == "(" ? true : false); $sucet += ($stav[i] ? 1 : -1) } $M.times do print "Zadaj udalost: "; udalost = readline.to_i if udalost > 0 $stav[udalost-1] = !$stav[udalost-1] $sucet += ($stav[udalost-1] ? 2 : -2) else puts(je_dobry ? "ANO" : "NIE") end end