Compiler Hanged Over

Правка en1, от alirezaopmc, 2020-03-12 22:19:41

Hello force coders, I was just solving a problem (1324A - Yet Another Tetris Problem) and my code was this:

#include <bits/stdc++.h>
using namespace std;

#define ll long long

#define li(n) for(int i=0; i<n; i++)

void test();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
	cin >> t;
	while(t--) {
		test();
		cout << endl;
	}
}

void test() {
	int n;
	cin >> n;
	int pre, cur;
	cin >> pre;
	li(n-1) {
		cin >> cur;
		pre%=2;
		cur%=2;
		if(pre==cur) continue;
		else {
			cout << "NO";
			return;
		}
	}
	cout << "YES";
	return;
}

and the tried to check my solution by given test cases, but the operation of taking input was amazingly wonderful. Input:

4
3
1 1 3
4
1 1 2 1
2
11 11
1
100

My Code's Output: (also containing inputs)

4
3
1 1 3
YES
4
1 1 2 1
NO
2 // how?
YES
11 11
1
100
NO

I was wondered why would something like this happen in C++. Likewise I had same problem on some interactive problems before. That Was (1385D - a-Good String)

Any idea?

Теги #cpp, #bug

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский alirezaopmc 2020-03-12 22:25:23 28 Submission link for problem D + link fixed
en1 Английский alirezaopmc 2020-03-12 22:19:41 1110 Initial revision (published)