Please read the new rule regarding the restriction on the use of AI tools. ×

homakov's blog

By homakov, 15 years ago, translation, In English
It was funny, especially #1 =)
it=gets.chomp.to_i;
p (it%2==0 and it!=2)?"YES":"NO";

Second task was pretty good, not same as my ugly code :)

d,sumTime=gets.split(" ");
d=d.to_i()
sumTime=sumTime.to_i()
i=0;
time=[];
maxTime=[];
full_count=0;
minSum=0;
maxSum=0;
while ggets=gets
  x,y=ggets.split(" ");
  x=x.to_i();
  y=y.to_i();
  full_count+=x;
  minSum+=x;
  maxSum+=y;
  time[i]=x.to_i;
  maxTime[i]=y.to_i;
  i+=1;
end

if sumTime>maxSum or sumTime<minSum
  puts 'NO';
else

i=0;
while full_count!=sumTime

if i==d
i=0;
end
  if(maxTime[i]>time[i])
  time[i]+=1;
  full_count+=1;
  else
  next
end

i+=1;
end

puts 'YES';
p time.join(" ");
end
THIRD:
count=gets.chomp.to_i();
base={}
answer='';
out='';
count.times do
g=gets.chomp.to_s;

if base[g]!=1
base[g]=1;
out+="OK\n";
else
cnt=0;

while true
cnt+=1;
answer=g+cnt.to_s();

if base[answer]!=1
    base[answer]=1
    out+=answer+"\n";
    break
end

end
end

end

puts out

Btw, second code hadn't worked right, anybody know why? 
  • Vote: I like it
  • +1
  • Vote: I do not like it

15 years ago, # |
  Vote: I like it 0 Vote: I do not like it
>> Btw, second code hadn't worked right, anybody know why?
What exactly the mistake is?

Here is my 3rd. Looks nice to me:
n = gets.chomp.to_i
h = {}
n.times do
  s = gets.chomp
  if h[s].nil? then
    puts 'OK'
    h[s] = 1
  else
    puts s + h[s].to_s
    h[s] += 1
  end  
end

And, the main question is -- have you managed to pass the time limit in D?
  • 15 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    Разные EN-RU версии постов поистине верх неудобства.

    >> Вторая кстати не прошла валидацию, подскажите почему?
    Какой вердикт?

    И, кстати, этот chomp  в первой существенен: без него в 8 тесте внезапно появляются пробельные символы и получается RE.
    • 15 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      >  puts s + h[s].to_s
          h[s] += 1
      вкусный кусок, +1 я бы недогадался сразу.

      >have you managed to pass the time limit in D?
      Не успел решить D. там судя по всему рекурсия и Ruby не подошел бы.

      Еще вот это до меня только потом дошло:
      while ggets=gets использовать нельзя, а нужно n.times do
        s = gets.chomp делаю вывод тестирующий сервер не умеет делать interrupt в консоль.
      • 15 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        >> Не успел решить D. там судя по всему рекурсия >> и Ruby не подошел бы.

        У меня рекурсивное решение падает на 25 тесте и итеративное на 23. Я пока что верю, что она не сдаётся на Ruby :)