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 1127. Colored Bricks

I got Compilation Error!!! What is wrong???
Posted by Algorithmus_UA(algorithmus@univ.kiev.ua) 14 Aug 2002 02:10
----------------PROGRAM---------------
const col:array[1..10]of char =
('A','B','C','G','O','R','S','V','W','Y');
var
    a:array[1..10,1..10,1..10,1..10]of integer;
    hash1:array[0..255]of integer;
    N,k,max,i,k1,k2,k3,k4:integer;
    f,r,l,re,t,b:char;
    s,rrr:string;

procedure addnew;
var min:char;
    i,l:integer;
begin
  rrr[0]:=#4;
  min:=#255;
  for i:=1 to 4 do if s[i]<min then
  begin
    min:=s[i];
    l:=i;
  end;
  for i:=l to 4 do rrr[i-l+1]:=s[i];
  for i:=1 to l-1 do rrr[i+4-l+1]:=s[i];
  inc(a[ord(rrr[1]),ord(rrr[2]),ord(rrr[3]),ord(rrr[4])]);
end;

begin
  for i:=1 to 10 do hash1[ord(col[i])]:=i;
{  assign(input,'1127.dat');reset(input);}
  readln(N);
  for k:=1 to N do
  begin
    readln(s);
    for i:=1 to 6 do
     s[i]:=chr(hash1[ord(s[i])]);
    f:=s[1];r:=s[2];l:=s[3];re:=s[4];t:=s[5];b:=s[6];
    s[0]:=#4;
    s[1]:=f;s[2]:=l;s[3]:=re;s[4]:=r;
    addnew;
    s[1]:=t;s[2]:=re;s[3]:=b;s[4]:=f;
    addnew;
    s[1]:=t;s[2]:=r;s[3]:=b;s[4]:=l;
    addnew;
  end;
  max:=0;
  for k1:=1 to 10 do for k2:=1 to 10 do for k3:=1 to 10 do for k4:=1
to 10 do
  if a[k1,k2,k3,k4]>max then max:=a[k1,k2,k3,k4];
  writeln(max);
end.
You cannot access 0-the element of string. (+)
Posted by Oberon (Yura Znovyak) 14 Aug 2002 15:56
If they use delphi compiler, then the error can be next---Just follow the line :)                                   |
>  const col:array[1..10]of char =                        |
> ('A','B','C','G','O','R','S','V','W','Y');              |
> var                                                     |
>     a:array[1..10,1..10,1..10,1..10]of integer;         |
>     hash1:array[0..255]of integer;                      |
>     N,k,max,i,k1,k2,k3,k4:integer;                      |
>     f,r,l,re,t,b:char;                                  |
>     s,rrr:string;                                       |
>                                                         |
> procedure addnew;                                       |
> var min:char;                                           |
>     i,l:integer;                                        |
> begin                                                   |
>   rrr[0]:=#4; <<<- I think this can be an error.<<<-----/
>   min:=#255;                                            |
>   for i:=1 to 4 do if s[i]<min then                     |
>   begin                                                 |
>     min:=s[i];                                          |
>     l:=i;                                               |
>   end;                                                  |
>   for i:=l to 4 do rrr[i-l+1]:=s[i];                    |
>   for i:=1 to l-1 do rrr[i+4-l+1]:=s[i];                \-->   inc(a[ord(rrr[1]),ord(rrr[2]),ord(rrr[3]),ord(rrr[4])]); |
> end;                                                    /--/
>                                                         |
> begin                                                   |
>   for i:=1 to 10 do hash1[ord(col[i])]:=i;              |
> {  assign(input,'1127.dat');reset(input);}              |
>   readln(N);                                            |
>   for k:=1 to N do                                      |
>   begin                                                 |
>     readln(s);                                          |
>     for i:=1 to 6 do                                    |
>      s[i]:=chr(hash1[ord(s[i])]);                       |
>     f:=s[1];r:=s[2];l:=s[3];re:=s[4];t:=s[5];b:=s[6];   |
>     s[0]:=#4; <<< And probably this too <<<-------------/
>     s[1]:=f;s[2]:=l;s[3]:=re;s[4]:=r;
>     addnew;
>     s[1]:=t;s[2]:=re;s[3]:=b;s[4]:=f;
>     addnew;
>     s[1]:=t;s[2]:=r;s[3]:=b;s[4]:=l;
>     addnew;
>   end;
>   max:=0;
>   for k1:=1 to 10 do for k2:=1 to 10 do for k3:=1 to 10 do for
k4:=1
> to 10 do
>   if a[k1,k2,k3,k4]>max then max:=a[k1,k2,k3,k4];
>   writeln(max);
> end.
Thank's!
Posted by Algorithmus_UA(algorithmus@univ.kiev.ua) 15 Aug 2002 01:32
Thank's!
Re: Thank's!
Posted by nicushor 17 Mar 2003 17:21
> Thank's!hahaha