Source Code
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int cnt[2][2];

int main() {
    int n, k, m;
    cin >> n >> k >> m;

    for (int i = 0; i < n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        cnt[x & 1][y & 1]++;
    }

    bool have1 = cnt[0][0] || cnt[1][1];
    bool have2 = cnt[0][1] || cnt[1][0];

    int initSum = (cnt[1][0] + cnt[1][1]) & 1;

    int winner = 0;

    if (!have2) {
        winner = (initSum == m ? 1 : 2);
    } else if (!have1) {
        winner = ((initSum ^ (k & 1)) == m ? 1 : 2);
    } else {
        winner = (k & 1) ? 1 : 2;
    }

    cout << winner << endl;
}
Copy
Cliffs of Dover Baraa_Armoush
GNU G++17
165 ms
880 KB
Accepted