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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k, m, p = 0, same = 0, diff = 0;
    cin >> n >> k >> m;
    bool win;

    while(n --){
        int x, y;
        cin >> x >> y;
        p += x;
        p %= 2;
        same += (x % 2 == y % 2);
        diff += (x % 2 != y % 2);
    }

    if(!same){  
        p ^= (k & 1);
        win = (m == p);
    }else if(!diff)
        win = (m == p);   
    else
        win = (k & 1);

    cout << (win ? 1 : 2) << '\n';
}
Copy
Cliffs of Dover ahmad_salah
GNU G++17
132 ms
916 KB
Accepted