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

Обсуждение задачи 1100. Таблица результатов

Why WA on Test 1??
Послано Kobzarev Ivan 21 апр 2004 00:53
#include <iostream.h>
#include <fstream.h>
long n;

//const char fin[20] = "st.in";
//      char fout[20] = "st.out";

struct tp_
   {
      long id;
      long w;
   };
tp_ a[1000];
void rf()
   {
  //     ifstream ifs(fin);
  //   cin = ifs;
       cin >> n;
       long i, x, y;
       for (i = 1; i <= n; i++)
      {
        cin >> x >> y;
        a[i].id = x;
        a[i].w = y;
      }
   }

void sort (long l, long r)
   {
       tp_ y;
       long i, j, x;
       i = l;
       j = r;
       x = a[(l + r) / 2].w;
      do
      {
           while (x < a[i].w) i++;
           while (x > a[j].w) j--;
          if (i <= j)
             {
             y = a[i];
             a[i] = a[j];
             a[j] = y;
             i++;
             j--;
             }
      }
      while (i <= j);
      if (l < j) sort (l, j);
      if (i < r) sort (i, r);
    }

void wf()
   {
  //     ofstream ofs(fout);
  //     cout = ofs;
       long i;
       for (i = 1; i <= n;  i++) cout << a[i].id <<" "<<a[i].w<<endl;
   }

int main()
    {
       rf();
      sort(1, n);
       wf();
       return 0;
    }
Re: Why WA on Test 1??
Послано Боян Иванов (Boyan Ivanov) 30 апр 2005 03:05
I also got a wrong answer,but I think that the test is not correct since in the description of the problem nothing is said on how to sort teams who have equal number solved problems.Here's my output and after it you'll see the sample one :
3 5
26 4
22 4
20 3 <= look
16 3 <= here
1 2
11 2
7 1

3 5
26 4
22 4
16 3 <= look
20 3 <= here
1 2
11 2
7 1

And the input is the same,I just pasted in a txt file from the site.
Re: Why WA on Test 1??
Послано Marko Bogdanovic 6 май 2005 06:11
Yes, I don't understand either what if m is equals, on one place in sample first go bigger id, then on other place first is smaller id ?!! I thought then, first we output one which is first readed, but that also isn't rule.

So, is it possible that there is a mistake in sample?

Edited by author 06.05.2005 06:16
Re: Why WA on Test 1??
Послано zzq 14 июл 2006 19:53
I got AC!
I thought that first we output one which is first readed.
It's all right!
Just do it!
Re: Why WA on Test 1??
Послано Squid 15 авг 2006 16:09
Hint.
Bubble sort is a stable sort (that means that two teams with the equal number of solved problems must be listed in the output in the same order as they did in the input)
And quicksort is not a stable sort, so don't use it!
Re: Why WA on Test 1??
Послано Fokysnik 22 авг 2006 12:36
Yes. But there should be said something about IDs in the problem!!!
Re: Why WA on Test 1??
Послано Aracon 18 апр 2007 21:01
It's said:
" a program, which generates _exactly_ the same final standings as old software"
So, output of your program must be equal to output of bubble-sort program, and sequence of ID's should be the same.