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

int main() {
	int n , p ;
	cin >> n;
	vector <int> x ;
	for ( int i = 0 ; i < n ; i++ ) {
		cin >> p ;
		if(!i)x.push_back(p);
		if (i > 0 && p%2 != x[i-1]%2 ) {
			x.push_back(p);
		}
	}
	int c = 0 ;
	for ( int i = 0 ; i < x.size() ; i++ ) {
		c += (x[i]%2?0:1);
	}
	cout << (x.size()==1?0:c-1) ;
	return 0;
}
Copy
Teleportation SAAD
GNU G++17
0 ms
576 KB
Wrong Answer