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

const int N = 1e5 + 5;

int main()
{
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    int n, k, m;
    cin >> n >> k >> m;
    bool z = false, o = false;
    int p = 0;
    for(int i = 0 ; i < n ; i++)
    {
        int x, y;   cin >> x >> y;
        p ^= (x&1);
        if((x&1) == (y&1)) z = true;
        else o = true;
    }

    if(z && !o) cout << (m == p ? 1 : 2);
    else if(!z && o) cout << (p^(k&1) == m ? 1 : 2);
    else cout << (k%2 == 1 ? 1 : 2);
}
Copy
Cliffs of Dover EsmaelSufe
GNU G++17
116 ms
888 KB
Accepted