Hi all,
I've been trying to solve this problem at TOJ.
I am recieving TLE for following simple code (I just scan input):
#include <iostream>
#include <algorithm>
using namespace std;
int m, n, res;
int b[500];
int r[500];
int main()
{
while (true) {
cin >> m;
cin >> n;
if (m == 0 && n == 0)
break;
for (int i = 0; i < m; i++)
cin >> b[i];
for (int i = 0; i < n; i++)
cin >> r[i];
}
return 0;
}
If any of you is familiar with (have been solving problems for long time) TOJ, please tell me what is wrong.
Try to use scanf() instead of cin.
(As I thought) No, it didn't help. Actually if I print something, then verdict is Output Limit Exceeded. I think there is a problem in testdata. :(
But if there is problem in testdata, then how 66 people got AC?! :(
Are you sure you have to input from console?
Well FAQ says stdio but who knows?:D (also notice "Multiple test files" on the problem's page)
BTW, 10 million numbers are too much. Also try to input using following technique:
cin.read(big_buffer, size);
It helps sometimes.
Multiple test files = multiple test cases in one input. Many online judges put that note somewhere. If the output was to a file, the filename would be specified.
Where are you getting 10 million numbers from?
My AC solution just uses scanf.
Can you please send your code to me? I just want to experiment on it.
Here is my code. I did something strange to check if gcd of 2 numbers is greater than 1 and I don't remember why (I solved this problem more than year ago).
Thanks for your code. Reason you check if gcd is greater than 1 is, you can pair cards only if gcd > 1.
I know that, I just did it in a strange way.
Thanks to everbody, especially Fcdkbear.
I spent a day (yesterday) to find out why I was recieving TLE for such simple code. Here is what had happened:
Yeah, such things happen in life, and you can just live this moments :)