Koa the Koala and her best friend want to play a game. The game starts with an array a of length n consisting of non-negative integers. Koa and her best friend move in turns and each have initially a score equal to 0 . Koa starts.

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;
const int maxn = 3e5 + 7;
const int INF = 2e9;

int a[maxn];

int main() {
    int T;scanf("%d",&T);
    while(T--) {
        int n;scanf("%d",&n);
        for(int i = 1;i <= n;i++) {
            scanf("%d",&a[i]);
        }
        int flag = 0;
        for(int i = 30;i >= 0;i--) {
            int cnt = 0;
            for(int j = 1;j <= n;j++) {
                if(a[j] & (1 << i)) {
                    cnt++;
                }
            }
            if(cnt % 2 == 1) {
                if(cnt % 4 == 1) {
                    flag = 1;
                } else {
                    if(n % 2 == 1) flag = -1;
                    else flag = 1;
                }
                break;
            }
        }
        if(flag == 1) {
            printf("WIN\n");
        } else if(flag == 0) {
            printf("DRAW\n");
        } else {
            printf("LOSE\n");
        }
    }
    return 0;
}

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source