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

why do i get "access violation"?
Posted by GAV_of_ExE 3 Oct 2002 00:43
program  cubic;

type  Tr=record
        b,
        e:Longint;
        u:boolean;
      end;


var  cubics:array [0..1000,0..3] of string[7];
     n,i,j,k,result:integer;


procedure setfirst(var str:string);
var odd,i,num:byte;
    tmp,tmp2:string;
    c:char;
begin
num:=1;
odd:=90;
tmp:='';
tmp2:='';
for i:=1 to 4 do
    begin
    if ord(str[num])>ord(str[i]) then num:=i;
    end;

for i:=1 to (num-1) do
    begin
    tmp:=tmp+str[i];
    end;

for i:=num to 4 do
    begin
    tmp2:=tmp2+str[i];
    end;

str:='';
str:=tmp2+tmp;

if ord(str[2])>ord(str[4]) then
   begin
   c:=str[2];
   str[2]:=str[4];
   str[4]:=c;
   end;

end;



procedure ReadData;
var str:string;
begin
    readln(n);
    for i:=1 to n do
    begin
         readln(cubics[i,0]);
         cubics[i,1]:=cubics[i,1]+cubics[i,0,1];
         cubics[i,1]:=cubics[i,1]+cubics[i,0,2];
         cubics[i,1]:=cubics[i,1]+cubics[i,0,4];
         cubics[i,1]:=cubics[i,1]+cubics[i,0,3];
         str:=cubics[i,1];
         setfirst(str);
         cubics[i,1]:=str;

         cubics[i,2]:=cubics[i,2]+cubics[i,0,2];
         cubics[i,2]:=cubics[i,2]+cubics[i,0,5];
         cubics[i,2]:=cubics[i,2]+cubics[i,0,3];
         cubics[i,2]:=cubics[i,2]+cubics[i,0,6];
         str:=cubics[i,2];
         setfirst(str);
         cubics[i,2]:=str;

         cubics[i,3]:=cubics[i,3]+cubics[i,0,1];
         cubics[i,3]:=cubics[i,3]+cubics[i,0,5];
         cubics[i,3]:=cubics[i,3]+cubics[i,0,4];
         cubics[i,3]:=cubics[i,3]+cubics[i,0,6];
         str:=cubics[i,3];
         setfirst(str);
         cubics[i,3]:=str;

    end;

end;

procedure WriteData;
var str:string;
begin
    for i:=1 to n do
    begin
         for j:=1 to 3 do

             writeln(cubics[i,j]);
         writeln;

    end;
writeln(result);
end;



procedure RUN;
var str:string;
var k,l,k1,temp:integer;
begin


result:=1;
temp:=1;
for i:=1 to n do
begin
     for j:=1 to 3 do
     begin
          str:=cubics[i,j];
          for k:=1 to (n-1) do
          begin
          k1:=k1+1;
          if k1=i then k1:=k1+1;
               for l:=1 to 3 do
               begin
                    if str=cubics[k1,l] then
                    begin
                    temp:=temp+1;

                    end;

               end;

          end;

     if temp>result then
     result:=temp;
     temp:=1;

     end;

end;
end;


begin
    init;
    readdata;
    run;
    writedata;
end.