ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1167. Bicolored Horses

Why WA? (my solution included) So... Simply say what traps are in this problem. PLEASE!
Posted by Igor Zubchenok (Belarus SU) 15 Dec 2001 17:08
const maxH=500;
var N,K,q,w,e:longint;
    H:array[1..maxH] of longint;
    z:array[1..2,1..maxH,0..2] of longint;
    x:array[0..1] of longint;

begin
readln(N,K);
for q:=1 to N do
  readln(h[q]);

for q:=1 to K do
  begin
  z[2,q,0]:=0;
  z[2,q,1]:=0;
  z[2,q,2]:=0;
  end;
z[2,1,h[1]]:=1;

for q:=2 to N do
  begin
  z[1]:=z[2];
  for e:=1 to K do
    begin
    z[2,e,0]:=0;
    z[2,e,1]:=0;
    z[2,e,2]:=0;
    end;
  z[2,1]:=z[1,1];
  z[2,1,h[q]]:=z[2,1,h[q]]+1;

  e:=K;
  if q<K then e:=q;
  for w:=2 to e do
    begin
    x[0]:=z[1,w,0];
    x[1]:=z[1,w,1];
    x[h[q]]:=x[h[q]]+1;

    z[2,w,h[q]]:=1;
    z[2,w,2]:=z[1,w-1,0]*z[1,w-1,1]+z[1,w-1,2];

    if z[2,w,2]>z[1,w,2]+x[0]*x[1] then
      begin
      z[2,w,0]:=x[0];
      z[2,w,1]:=x[1];
      z[2,w,2]:=z[1,w,2];
      end;
    end;
  end;
writeln(z[2,K,0]*z[2,K,1]+z[2,K,2]);
end.
I'm sorry but ur solution is not correct :(
Posted by I have answers to all your questions :) 16 Dec 2001 18:40
Re: I'm sorry but ur solution is not correct :(
Posted by Igor Zubchenok (Belarus SU) 18 Dec 2001 22:59
Could you give me a test on which my solution gives wrong answer?
Why not ? :">
Posted by I have answers to all your questions :) 18 Dec 2001 23:24
7 2
1
1
0
0
1
1
1
Re: Why not ? :">
Posted by Mewtwo 24 Sep 2017 19:28
Isn't the correct answer 4?
I have answers to all your questions :) wrote 18 December 2001 23:24
7 2
1
1
0
0
1
1
1