Source Code
#include <iostream>
using namespace std ;
int main() 
{
  long long n ,k , sum = 0 , cnt = 0 , win;
  int m;
  cin>>n>>k>>m;
  while(n--)
  {
    int x , y;
    cin>>x>>y ;
    if ((x%2!= y%2)) cnt ++;
    sum+=x;

  }
  
  
  // when there is no need to flip any card (no difference between parities ) or if i can flip all cards
  if(cnt ==0 || cnt == n ) 
  {
    
    if(sum % 2 ==m  ) win = 1;
    else win = 2;
   
  }
    
  /*else if (cnt == n )
  {
    if(sum % 2==0 && m==0 &&k % 2 ==1  ) win = 1;
    else if(sum % 2 == 1 && m= )
    else win = 2;

    }*/
    else 
    {
      
      if(k%2 == m)win=1;
      else win=2;
    }
    cout<<win;
}
Copy
Cliffs of Dover Tala_Ibraheem
GNU G++17
271 ms
744 KB
Wrong Answer