Source Code
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N], b[N];
int n, m;
int main(){
// int t;cin>>t;while(t--){
	int p, k;
	scanf("%d%d%d",&n,&k,&p);
	bool l1 = 0, l2 = 0;
	int sm = 0, x, y;
	for(int i=0; i<n; ++i){
		scanf("%d%d",&x,&y);
		sm += x;sm %= 2;
		if(x%2 != y%2){
			l1 = 1;
		}
		if(x%2 == y%2){
			l2 = 1;
		}
	}
	if(sm==p){
		if(k%2){
			if(l2){
				cout<<1<<endl;
			}
			else{
				cout<<2<<endl;
			}
		}
		else{
			if(!l2){
				cout<<1<<endl;
			}
			else if(l1){
				cout<<2<<endl;
			}
			else{
				cout<<1<<endl;
			}
		}
	}
	else{
		if(k%2){
			if(l1){
				cout<<1<<endl;
			}
			else{
				cout<<2<<endl;
			}
		}
		else{
			cout<<2<<endl;
		}
	}

// }
return 0;
}
Copy
Cliffs of Dover Zain
GNU G++17
150 ms
1.0 MB
Accepted