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 1100. Final Standings

Why WA on Test 1??
Posted by Kobzarev Ivan 21 Apr 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??
Posted by Боян Иванов (Boyan Ivanov) 30 Apr 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??
Posted by Marko Bogdanovic 6 May 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??
Posted by zzq 14 Jul 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??
Posted by Squid 15 Aug 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??
Posted by Fokysnik 22 Aug 2006 12:36
Yes. But there should be said something about IDs in the problem!!!
Re: Why WA on Test 1??
Posted by Aracon 18 Apr 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.