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 1446. Sorting Hat

Wa test 1?
Posted by Sergio Marquez 18 Sep 2006 00:09
I show the correct answer but tell me WA. why?
Re: Wa test 1?
Posted by mariam kupatadze 12 Feb 2008 21:28
I can tell you that it is very simple test but there some important things that must be forseen,so one of them is that when you write,for example, a,b:string; you must not read it like this readln(a,b); or read(a,b);
 you must write separately like this readln(a);
                                     readln(b);
So I will write my program for you :)

program amoc1446;
var a,b:array[1..1000] of string[200];
    i,n:integer;
begin
    readln(n);
    for i:=1 to n do
    begin
        readln(a[i]);
        readln(b[i]);
    end;

          writeln('Slytherin:');
  for i:=1 to n do
    if b[i]='Slytherin' then
      writeln(a[i]);
      writeln;

  writeln('Hufflepuff:');
  for i:=1 to n do
   if b[i]='Hufflepuff' then
     writeln(a[i]);
     writeln;

  writeln('Gryffindor:');
  for i:=1 to n do
    if b[i]='Gryffindor' then
      writeln(a[i]);
      writeln;
  writeln('Ravenclaw:');
  for i:=1 to n do
    if b[i]='Ravenclaw' then
      writeln(a[i]);

end.
Re: Wa test 1?
Posted by mariam kupatadze 12 Feb 2008 21:29
I can tell you that it is very simple test but there are some important things that you must  forseen,so one of them is that when you write,for example, a,b:string; you must not read it like this readln(a,b); or read(a,b);
 you must write separately like this readln(a);
                                     readln(b);
So I will write my program for you :)

program amoc1446;
var a,b:array[1..1000] of string[200];
    i,n:integer;
begin
    readln(n);
    for i:=1 to n do
    begin
        readln(a[i]);
        readln(b[i]);
    end;

          writeln('Slytherin:');
  for i:=1 to n do
    if b[i]='Slytherin' then
      writeln(a[i]);
      writeln;

  writeln('Hufflepuff:');
  for i:=1 to n do
   if b[i]='Hufflepuff' then
     writeln(a[i]);
     writeln;

  writeln('Gryffindor:');
  for i:=1 to n do
    if b[i]='Gryffindor' then
      writeln(a[i]);
      writeln;
  writeln('Ravenclaw:');
  for i:=1 to n do
    if b[i]='Ravenclaw' then
      writeln(a[i]);

end.
Sergio Marquez wrote 18 September 2006 00:09
I show the correct answer but tell me WA. why?