Source Code
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1e6 + 10 ;

int arr[MAX] ;
int n , k , m ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>k>>m ;
	bool flag1 = false , flag2 = false ;
	int sum = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		if(x%2 == y%2)
			flag1 = true ;
		else
			flag2 = true ;
		sum = (sum + x) % 2 ;
	}
	if(flag1 && flag2)
	{
		if(k&1)
			cout<<1<<"\n" ;
		else
			cout<<2<<"\n" ;
	}
	else if(flag1)
	{
		if(m == sum)
			cout<<1<<"\n" ;
		else
			cout<<2<<"\n" ;
	}
	else if(flag2)
	{
		if(k & 1)
			sum = !sum ;
		if(m == sum)
			cout<<1<<"\n" ;
		else
			cout<<2<<"\n" ;
	}
	return 0 ;
}
Copy
Cliffs of Dover Bakry_
GNU G++17
127 ms
936 KB
Accepted