Chef and Table Tennis Solution

 

Problem 

Chef likes to play table tennis. He found some statistics of matches which described who won the points in order. A game shall be won by the player first scoring 11 points except in the case when both players have 10 points each, then the game shall be won by the first player subsequently gaining a lead of 2 points. Could you please help the Chef find out who the winner was from the given statistics? (It is guaranteed that statistics represent always a valid, finished match.)

Input

The first line of the input contains an integer T, denoting the number of test cases. The description of T test cases follows. Each test case consist a binary string S, which describes a match. '0' means Chef lose a point, whereas '1' means he won the point.

Output

For each test case, output on a separate line a string describing who won the match. If Chef won then print "WIN" (without quotes), otherwise print "LOSE" (without quotes).

Constraints

1 ≤ T ≤ 1000 1 ≤ length(S) ≤ 100

Sample 1:

Input
Output
2
0101111111111
11100000000000
WIN
LOSE

Explanation:

Example case 1. Chef won the match 11:2, his opponent won just two points, the first and the third of the match.

Example case 2. Chef lost this match 11:3, however he started very well the match, he won the first three points in a row, but maybe he got tired and after that lost 11 points in a row.





Program :


#include <stdio.h>

#include <string.h>

int main(void) {

 // your code goes here

 int t;

 scanf("%d",&t);

  while(t--)

  {

      int a=0,b=0;

      char s[100];

      scanf("%s",s);

      for(int i=0;i<strlen(s);i++)

      {

          if(s[i]=='1')

          {

              a++;

          }

          else b++;

      }

        if(a>b)

        {

            printf("WIN\n");

        }

        else printf("LOSE\n");

  }

 return 0;

}


Post a Comment

0 Comments