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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, p;
    cin >> n >> k >> p;
    int oddface = 0, oddother = 0;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        if (a % 2)
            oddface++;
        if (b % 2)
            oddother++;
    }
    int evenface = n - oddface, evenother = n - oddother;
    if (p == 1)
    {
        if ((oddface == 0 && oddother == 0) || (oddface == n && oddother == n && n % 2 == 0))
        {
            cout << 2;
            return 0;
        }
        if (oddface == n && oddother == n && n % 2)
        {
            cout << 1;
            return 0;
        }
        if (oddother == n || oddface == n)
        {
            if (oddface % 2 == 0)
            {
                if (k % 2 == 0)
                {
                    cout << 2;
                    return 0;
                }
                cout << 1;
                return 0;
            }
            else
            {
                if (k % 2 == 0)
                {
                    cout << 1;
                    return 0;
                }
                cout << 2;
                return 0;
            }
        }
        if (oddface % 2 == 0)
        {
            if (k % 2 == 0)
            {
                cout << 2;
                return 0;
            }
            cout << 1;
            return 0;
        }
        else
        {
            if (k % 2 == 0)
            {
                cout << 1;
                return 0;
            }
            cout << 2;
            return 0;
        }
    }
    else
    {
        if ((oddface == 0 && oddother == 0) || (oddface == n && oddother == n && n % 2 == 0))
        {
            cout << 1;
            return 0;
        }
        if (oddface == n && oddother == n && n % 2)
        {
            cout << 2;
            return 0;
        }
        if (oddother == n || oddface == n)
        {
            if (oddface % 2 == 0)
            {
                if (k % 2 == 0)
                {
                    cout << 1;
                    return 0;
                }
                cout << 2;
                return 0;
            }
            else
            {
                if (k % 2 == 0)
                {
                    cout << 2;
                    return 0;
                }
                cout << 1;
                return 0;
            }
        }
        if (oddface % 2 == 0)
        {
            if (k % 2 == 0)
            {
                cout << 1;
                return 0;
            }
            cout << 2;
            return 0;
        }
        else
        {
            if (k % 2 == 0)
            {
                cout << 2;
                return 0;
            }
            cout << 1;
            return 0;
        }
    }
}
Copy
Cliffs of Dover monther abu zaina1
GNU G++17
59 ms
660 KB
Wrong Answer