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 1219. Symbolic Sequence

Help this gets WA. I wrote test program it says that everything is OK? Help
Posted by Evil Hacker 23 Mar 2003 23:01
program SymbolicSequence; {.$APPTYPE CONSOLE}
var
    RndSeed: LongInt;

function MyRandom(Range: Integer): Integer;
var
    RDouble: Extended;
begin
    MyRandom := (RndSeed div 10000) mod Range;

    RDouble := RndSeed;
    RDouble := (RDouble * 3141592621 + 184421);
    RDouble := RDouble - $7FFFFFFF*Int(RDouble/$7FFFFFFF);
    RndSeed := Trunc(RDouble);
end;

var
    i: Integer;
begin
    RndSeed := 98586100;
    for i := 1 to 1000000 do
        Write(Chr(MyRandom(26) + Ord('a')));
    WriteLn;
end.

{ The tester program  }
program test; {$APPTYPE CONSOLE}
const
    OneCnt = 39000;
    TwoCnt = 1600;
    TriCnt = 97;

var
    i: Integer;
    S: String[4];
    Use1: array['a'..'z'] of Word;
    Use2: array['a'..'z', 'a'..'z'] of Word;
    Use3: array['a'..'z', 'a'..'z', 'a'..'z'] of Word;

    Ch: Char;
begin
    FillChar(Use1, SizeOf(Use1), 0);
    FillChar(Use2, SizeOf(Use2), 0);
    FillChar(Use3, SizeOf(Use3), 0);

    S := '123';
    Read(S[1], S[2], S[3]);
    Inc(Use1[S[1]]);
    Inc(Use1[S[2]]);
    Inc(Use1[S[3]]);

    Inc(Use2[S[1], S[2]]);
    Inc(Use2[S[2], S[3]]);

    Inc(Use3[S[1], S[2], S[3]]);

    for i := 4 to 1000000 do
    begin
        Read(Ch);
        if Ch in ['a'..'z'] then
        begin
            Delete(S, 1, 1);
            S := S + Ch;

            Inc(Use1[S[3]]);
            Inc(Use2[S[2], S[3]]);
            Inc(Use3[S[1], S[2], S[3]]);

            if Use1[S[3]] > OneCnt then
            begin
                WriteLn('Letter ', S[3], ' used more than ',
                          OneCnt, ' times!!!');
                Halt;
            end;

            if Use2[S[2], S[3]] > TwoCnt then
            begin
                WriteLn('Digraph ', S[2],S[3], ' used more than ',
                       TwoCnt, ' times!!!');
                Halt;
            end;

            if Use3[S[1], S[2], S[3]] > TriCnt then
            begin
                WriteLn('Trigraph ', S[1],S[2],S[3],
                        ' used more than ', TriCnt, ' times!!!');
                Halt;
            end;
        end else
        begin
            WriteLn('Error!!!');
            WriteLn('Not small latin letter at ', i);
            Halt;
        end;
    end;

    WriteLn('Ok');
end.
Re: Help this gets WA. I wrote test program it says that everything is OK? Help
Posted by qw! 17 Feb 2007 20:39
Writeln in the end is odd.
Re: Help this gets WA. I wrote test program it says that everything is OK? Help
Posted by Alias (Alexander Prudaev) 25 Feb 2007 11:44
char s[1000005];

int p1[32];
int p2[32][32];
int p3[32][32][32];

bool ok()
{
    int i;
    for (i = 0; i < 1000000; i++)
        p1[s[i]]++;
    for (i = 1; i < 1000000; i++)
        p2[s[i-1]][s[i]]++;
    for (i = 2; i < 1000000; i++)
        p3[s[i-2]][s[i-1]][s[i]]++;

    for (i = 0; i < 26; i++)
        if (p1[i]>40000) return false;
    int j,k;
    for (i = 0; i < 26; i++)
        for (j = 0; j < 26; j++)
            if (p2[i][j]>2000) return false;
    for (i = 0; i < 26; i++)
        for (j = 0; j < 26; j++)
            for (k = 0; k < 26; k++)
                if (p3[i][j][k]>200) return false;
    return true;
}