Блог пользователя accidentallygivenfuck

Автор accidentallygivenfuck, 13 лет назад, По-английски

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.

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
13 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Try to use scanf() instead of cin.

»
13 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

My AC solution just uses scanf.

»
13 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

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:

  • I clicked to "Connect" to connect to internet and it connects in 2-3 seconds.
  • Then immediately I clicked "Submit" in problem page.
  • As I was not connected to internet the moment I clicked to "Submit", Firefox opened a cached page http://acm.tju.edu.cn/toj/submit.html where problem field didnt contain correct problem id. (not 3783 but 2823).
  • And all day I used that submit page which contained wrong problem id to submit my codes.
  • It turned out that I was submitting my code to wrong problem.

Yeah, such things happen in life, and you can just live this moments :)