ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1246. Собака на привязи

I got WA..........
Послано hello 14 июн 2004 09:07
I got WA on test 7 all the time......
I submited many times . But still WA.
Can anyone help me ?
This is my code :
------------------------------------------------------------
{$A+,B+,D+,E+,F+,G+,I+,L+,N+,O+,P+,Q+,R+,S+,T+,V+,X+}
{$M 16384,0,655360}
type
  node = record
          x , y : Array [0..201] Of LongInt ;
          tx , ty , lx , ly : LongInt ;
         end;
var
  up , down , right1 , right2 , right3 , now : node ;
  h : Array [1..5] Of LongInt ;
  i , n : LongInt ;
  t : Boolean ;

  procedure init ;
    var
      c : Char ;
      s : Set Of Char ;
    begin
     s := ['0'..'9','-'] ;
     With now do
      begin
       repeat
        read ( c ) ;
       until c in s ;
       if c = '-'
        then begin
              tx := 2 ; read ( c ) ;
             end
        else tx := 1 ;
       lx := 0 ;
       repeat
        Inc ( lx ) ;
        x[lx] := ord ( c ) - 48 ;
        read ( c ) ;
       until c = ' ' ;

       repeat
        read ( c ) ;
       until c in s ;
       if c = '-'
        then begin
              tx := 2 ; read ( c ) ;
             end
        else ty := 1 ;
       ly := 0 ;
       repeat
        Inc ( ly ) ;
        y[ly] := ord ( c ) - 48 ;
        read ( c ) ;
       until Not ( c in s ) ;
      end;
    end;

  procedure first ;
    begin
     up.ty     := 2 ; up.ly     := MaxInt ;
     down.ty   := 1 ; down.ly   := MaxInt ;
     right1.tx := 2 ; right1.lx := MaxInt ;
     right2.tx := 2 ; right2.lx := MaxInt ;
     right3.tx := 2 ; right3.lx := MaxInt ;
    end;

  Function  check_y ( h : node ) : Boolean ;{true:big}
    var
      i : LongInt ;
      judge : Boolean ;
    begin
     if h.ty <> now.ty then
      begin
       if h.ty = 1
        then check_y := false
        else check_y := true ;
       exit
      end;
     if h.ty = 1
      then judge := true
      else judge := false ;
     if h.ly <> now.ly then
      begin
       if h.ly < now.ly
        then check_y := judge
        else check_y := not judge ;
       exit ;
      end;

     for i := 1 to now.ly do
      if h.y[i] <> now.y[i] then
       begin
        if h.y[i] < now.y[i]
         then check_y := judge
         else check_y := not judge ;
        exit ;
       end;
     check_y := false ;
    end;

  Function  check_x ( h , now : node ) : Boolean ;{true:small}
    var
      i : LongInt ;
      judge : Boolean ;
    begin
     if h.tx <> now.tx then
      begin
       if h.tx = 1
        then check_x := false
        else check_x := true ;
       exit ;
      end;
     if h.tx = 1
      then judge := true
      else judge := false ;
     if h.lx <> now.lx then
      begin
       if h.lx < now.lx
        then check_x := judge
        else check_x := not judge ;
       exit ;
      end;

     for i := 1 to now.lx do
      if h.x[i] <> now.x[i] then
       begin
        if h.x[i] < now.x[i]
         then check_x := judge
         else check_x := not judge ;
        exit ;
       end;
     check_x := false ;
    end;

  procedure yes ;
    begin
     writeln ( 'cw' ) ;
    end;

  procedure no ;
    begin
     writeln ( 'ccw' ) ;
    end;

begin
 first ;
 readln ( n ) ;
 for i := 1 to n do
  begin
   init ;

   t := false ;
   if check_y ( up ) then
    begin
     h[1] := i ; up := now ;
     t := true ;
    end;
   if Not check_y ( down ) then
    begin
     h[2] := i ; down := now ;
     t := true ;
    end;
   if check_x ( right1 , now )
    then begin
          h[5] := h[4] ; right3 := right2 ;
          h[4] := h[3] ; right2 := right1 ;
          h[3] := i    ; right1 := now    ;
         end
    else if check_x ( right2 , now )
          then begin
                h[5] := h[4] ; right3 := right2 ;
                h[4] := i    ; right2 := now    ;
               end
          else if check_x ( right3 , now ) then
                begin
                 h[5] := i ; right3 := now ;
                end;
  end;

 if ( h[3] = h[2] ) or ( h[3] = h[1] ) then h[3] := h[4] ;
 if ( h[3] = h[2] ) or ( h[3] = h[1] ) then
  begin
   h[3] := h[5] ;
   if h[1] < h[3]
    then begin
          if ( h[2] > h[1] ) and ( h[2] < h[3] )
           then yes
           else no ;
         end
    else begin
          if ( h[2] > h[3] ) and ( h[2] < h[1] )
           then no
           else yes ;
         end;
   halt ;
  end;

 if h[1] < h[3]
  then begin
        if ( h[2] > h[1] ) and ( h[2] < h[3] )
         then no
         else yes ;
       end
  else begin
        if ( h[2] < h[1] ) and ( h[2] > h[3] )
         then yes
         else no ;
       end;
end.

Edited by author 14.06.2004 09:08