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

How is it possible to read data so fast?
Posted by Lomir 6 Jan 2007 09:46
1    1200747    19:47:15
26 май 2006    Гладких Максим    C    0.078    1 322 КБ

First i used stl vectors ant cin cout, and got 0.47sec.
Then i rewrite it using scanf() printf() and only one matrix. Got AC only in 0.218...
How to read ant write everything in less then 0.1sec!?
Re: How is it possible to read data so fast?
Posted by KIRILL(ArcSTU) 6 Jan 2007 14:08
Your algo may be improved
I got AC on Pascal in 0.187 with standart input (O(n) solution)
Re: How is it possible to read data so fast?
Posted by Lomir 6 Jan 2007 15:55
There is better algo then O(n)!?
I've just read data in matrix and print it back.
Re: How is it possible to read data so fast?
Posted by KIRILL(ArcSTU) 6 Jan 2007 16:47
It's strange
I don't think that standart i/o in C++ is longer than in Pascal
I use simple linear sort (O(n+m)).
1 cycle for input
1 cycle for finding places O(n)
1 cycle for output
Re: How is it possible to read data so fast?
Posted by Lomir 6 Jan 2007 17:24
I have 2 cicles:
one for input and plasing the ID to the apopreate location,
second for printing...
C++ i/o is very slow 0.45+sec. So i used C scanf() and pritnf(), and got only 0.234...

int main()
{
scanf("%d", &n);
for (i = 0; i < n; ++i)
{
scanf("%d %d", &ID, &m);
++data[m][0];
data[m][data[m][0]] = ID;
}
for (i = 100; i >= 0; --i)
for (j = 1; j <= data[i][0]; ++j)
printf("%d %d\n", data[i][j], i);
return 0;
}
Re: How is it possible to read data so fast?
Posted by KIRILL(ArcSTU) 6 Jan 2007 19:08
I don't know C++, but it seems that you are using dynamic
2-dimensional array. May be it's the reason
My solution uses 3 static arrays [1..150000]
If you want I will send my solution
I've got AC in 0.14 reading input char by char