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

int main() {
	int n,k,m;
    cin>>n>>k>>m;
    bool same = false;
    bool different = false;
    int parity = 0;
    for(int i=0;i<n;i++) {
        int a,b;
        cin>>a>>b;
        if(a%2==b%2)
            same = true;
        else if(a%2 != b%2)
            different = true;
        parity = (parity + a)%2;
    }

    if(!different) {
        cout<<(parity==m?1:2)<<endl;
    }
    else if(same) {
        cout<<(k%2==1?1:2)<<endl;
    }
	else {
        if(k%2==0)
            cout<<(parity==m?1:2)<<endl;
        else
            cout<<(parity!=m?1:2)<<endl;
    }

	return 0;
}
Copy
Cliffs of Dover Mr-Spy
GNU G++17
385 ms
876 KB
Accepted