Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,m,k;
    cin>>n>>k>>m;
    k%=2;
    ll sum=0;
    bool ok1=0,ok2=0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        x%=2;
        y%=2;
        if(x==y)ok1=1;
        else ok2=1;
        sum+=x;
    }
    sum%=2;
    if(k==0){
        if(!ok1&&m==sum)cout<<1;
        else cout<<2;
    }
    else{
        if(sum!=m){
            if(ok2)cout<<1;
            else cout<<2;
        }
        else{
            if(ok1)cout<<1;
            else cout<<2;
        }
    }

}
Copy
Cliffs of Dover Wesam
GNU G++17
87 ms
772 KB
Wrong Answer