Skip to content

Commit 5174b65

Browse files
authored
Merge pull request ashutosh97#49 from sarthakj2099/master
new question chefdil added
2 parents 3a37106 + 495f882 commit 5174b65

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

Chefdil/ans.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
int main()
4+
{
5+
int t;
6+
cin>>t;
7+
while(t--)
8+
{
9+
string a;
10+
cin>>a;
11+
int b=0;
12+
for(int i=0;i<a.size();i++)
13+
b+=a[i]-'0';
14+
//cout<<b;
15+
if(b%2)
16+
cout<<"WIN"<<endl;
17+
else
18+
cout<<"LOSE"<<endl;
19+
}
20+
}

Chefdil/ans.exe

1 MB
Binary file not shown.

Chefdil/ans.o

3.6 KB
Binary file not shown.

Chefdil/ques.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Chef has no work to do in the kitchen, so he decided to play a card game with the following rules:
2+
3+
Initially, N cards are placed in a row on a table. Each card is placed either face up or face down.
4+
The goal of the game is to remove all cards from the table, one by one.
5+
A card may be removed only if it is currently facing up.
6+
When a card is removed, its adjacent cards (the cards directly to its left and right, if they exist) are flipped, i.e. a card that was facing up will be facing down and vice versa.
7+
There is an empty space left behind each removed card, i.e. the remaining cards are not moved to create a contiguous row of cards again. Therefore, if the game starts with three cards and the middle card is removed, then the cards on the sides are flipped, but removing one of these cards afterwards does not cause the other card to be flipped, since it is only adjacent to the empty space created by removing the middle card.
8+
Determine whether Chef is able to win this game.
9+
10+
Input
11+
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
12+
The first line of each test case contains a single string S describing the row of cards initially placed on the table. Each character of this string is either '1', denoting a face up card, or '0', denoting a face down card.
13+
Output
14+
For each test case, print a single line containing the string "WIN" if Chef can win the game or "LOSE" if he cannot win (without quotes).
15+
16+
Constraints
17+
1=T=102
18+
1=|S|=105
19+
Subtasks
20+
Subtask #1 (30 points):
21+
22+
1=T=10
23+
1=|S|=100
24+
Subtask #2 (70 points): original constraints
25+
26+
Example Input
27+
1
28+
10
29+
Example Output
30+
WIN
31+
Explanation
32+
Example case 1: First, Chef should remove the first card, which makes the second card face up. Then, he should remove the second card. This way, all cards are removed and Chef wins.

0 commit comments

Comments
 (0)