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

Обсуждение задачи 1116. Кусочно-постоянная функция

If anybody plz will find some tests which're bad for that solution plz write me!
Послано Igor 7 янв 2002 19:08
Type Kusok = Record X,Y,P:Integer End;
Var
 F1,F2,F:Array [1..15000] Of kusok;
 J,U,I,N1,N2 : Integer;


Begin
{ Assign(Input,'InPut.txt');
  ReSet(InPut);{}
 Read(N1);
  For I:=1 To N1 Do
   With F1[I] Do
    Read(X,Y,P);
 Read(N2);
  For I:=1 To N2 Do
   With F2[I] Do
    Read(X,Y,P);
 J:=1;
 U:=0;
 For I:=1 To N2 Do
  Begin
{F1[J] is avoided}
   While F1[J].Y<F2[I].X Do
    Begin
     Inc(U);
     F[U]:=F1[J];
     Inc(J);
    End;

   While (F1[J].X<F2[I].Y) Do
    Begin
{F2[i] Covers right part of F1[J]}
     If (F1[J].X<F2[I].X) And (F1[J].Y<=F2[I].Y) Then Begin
                                                      Inc(U);
                                                      F[U].X:=F1[J].X;
                                                      F[U].Y:=F2[I].X;
                                                      F[U].P:=F1[J].P;
                                                      Inc(J);
                                                      End Else
{F2[I] Covers Left part of F1[J]}
    If (F1[J].X>=F2[I].X) And (F1[J].Y>F2[I].Y) Then Begin
                                                     F1[J].X:=F2[I].Y;
                                                     End Else
{f2[I] Cov all F1[J]}
     If (F1[J].X>=F2[I].X) And (F1[J].Y<=F2[I].Y) Then Begin
                                                       Inc(J);
                                                       End Else
{F2[I] Divides F1[J] into 2 parts}
     If (F1[J].X<F2[I].X) And (F1[J].Y>F2[I].Y) Then Begin
                                                     Inc(U);
                                                     F[U].X:=F1[J].X;
                                                     F[U].Y:=F2[I].X;
                                                     F[U].P:=F1[J].P;
                                                     F1[J].X:=F2[I].Y;
                                                     End;
     If J>N1 Then Break;
    End;
  End;
 For I:=J To N1 Do
  Begin
   Inc(U);
   F[U]:=F1[I];
  End;
{Assign(Output,'OutPut.txt');
ReWrite(OutPut);{}
 Write(U);
 For I:=1 To U Do
  Write(' ',F[I].X,' ',F[I].Y,' ',F[I].P);
End.
A test for you (+)
Послано shitty.Mishka 8 янв 2002 00:20
Try this case:
0
1 1 2 3

Of course, the output should be 0.

Hope this will help.
Good luck!
Re: A test for you (+)
Послано Igor 8 янв 2002 15:52
> Try this case:
> 0
> 1 1 2 3
>
> Of course, the output should be 0.
>
> Hope this will help.
> Good luck!
Thanx for luck, but unfortunately it worked fine fith all zero-
answers... Maybe some other... All mine've worked good.

                         Sincerely yours,
                                               Igor.;)
Thank you for your hint, I got AC!!
Послано Song Chao (ECUST Mutistar) 22 фев 2002 13:38
> Try this case:
> 0
> 1 1 2 3
>
> Of course, the output should be 0.
>
> Hope this will help.
> Good luck!
Thank you for your hint, I got AC!!
Послано Song Chao (ECUST Mutistar) 22 фев 2002 13:38
> Try this case:
> 0
> 1 1 2 3
>
> Of course, the output should be 0.
>
> Hope this will help.
> Good luck!