Source Code
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<int, int> pi;
const ll Mod = 998244353;
const ll INF = (ll)(1e18) + 5;
const ll N = 5e5 + 5, M = 18;


int main() {
	GO;
	
	int n, k, m; cin >> n >> k >> m;
	int sum = 0;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int x, y; cin >> x >> y;
		sum ^= x % 2;
		cnt += (x % 2 != y % 2);
	}
	int ans = 0;
	if (cnt == 0 || k == 0)
		ans = 1 + sum;
	else if (cnt == n)
		ans = (k % 2 == 0 ? 1 + sum : 1 + !sum);
	else { cout << 1 + !(k % 2) << endl; return 0; }
	if (m)
		ans = 3 - ans;
	cout << ans << '\n';
	return 0;
}
Copy
Cliffs of Dover Oxygen
GNU G++17
175 ms
976 KB
Accepted