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

Автор NutelIa, история, 7 лет назад, По-английски

I sent a code for problem C in this contest: http://codeforces.me/gym/100026 and I got runtime error (I didn't have runtime error in my computer nor in custom invocation). I couldn't find out where the error came from so I simplified my code (knowing it would get WA) to find the source. One of the last codes I sent was:

#include <bits/stdc++.h>

using namespace std;
struct punt{
	int x,y;
};
typedef vector < punt > VE;
int n,k;
VE mines, pals;
int main(){
	cin >> n >> k;
	pals = VE(n);
	mines = VE(k);
	for(int i = 0; i < n; i++) {
		int x,y;
		cin >> x >> y;
		pals[i] = {x,y};
	}
	for(int i = 0; i < k; i++) {
		int x,y;
		cin >> x >> y;
		mines[i] = {x,y};
	}
	cout << "** " << mines[0].x << ' ' << mines[0].y << endl;
}

And I still got runtime error. Checking the test case with a friend who has "coach mode" enabled I could find out k != 0 (as it corresponds to first test case in the sample). The source of the runtime error is the access to mines[0] but I don't understand why. Moreover, when I change the last few lines to these ones:

for(int i = 0; i < k; i++) {
	int x,y;
	cin >> x >> y;
	mines[i] = {x,y};
	cout << "** " << mines[i].x << ' ' << mines[i].y << endl;
}

I don't get runtime error. Instead this message is shown

alt text

Can someone help me? Is it a CF problem or mine?

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

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by NutelIa (previous revision, new revision, compare).

»
7 лет назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

it's not standard input!

freopen("mines.in", "r", stdin) ;
freopen("mines.out", "w", stdout) ;