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 == y);
        diff += (x != y);
    }

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

    cout << (win ? 1 : 2) << '\n';
}
Copy
Cliffs of Dover ahmad_salah
GNU G++17
53 ms
664 KB
Wrong Answer