TTENIS - Editorial

link text My solution is showing wrong answer.I had checked it for many test cases and got correct output.
Can anyone find the mistake.

gaddevarunteja,
You made the same mistake I just did. Problem statement isn’t clear enought (at least for non-english speaker). You use the rule “two ‘1’ in a row - win, tow ‘0’ in a row - lose”. It’s incorrect. You need to use (points1 - points2 == 2) --> win, (points2-points1==2) – lose.

1 Like

CodeChef: Practical coding for everyone MY SLUTION SHOWS WRONG ANSWER.CAN ANYONE HELP?

iam getting wrong answer,i have checked everything is correct and getting correct input and output…please help!!!

CodeChef: Practical coding for everyone please state what is wrong in my code…I desperately want to see where is the fault

Hello,
I had written a code for this question, which got passed and I got AC.

My solution: https://www.codechef.com/viewsolution/17920124

But I figured out a test case (1010101010101010101011000), for which my solution will give “LOSE” but the author’s solution will give “WIN”. I know that my solution is wrong according to the question. Please check the test cases being used to check our codes.

Whats wrong in my answer?
It is working fine,but giving wrong answer!!!
Can u tell where it fails?
Link to my WA solution
http://www.codechef.com/viewsolution/7198216

I think you program suppose that if the score one time is 10-10 than the winner is who earn 1 pont sooner this is not true. E.g the :
10-10 -> 11-10 , 11-11, 12-11, 12-12, 12-13, 12-14 than the second player won, but your program will be answer the first won…

@iscsi I think p1 won in this case, as p1 scored earliest 12 in the game after the draw. RIght?

I think just checking the last character is always a sufficient condition to determine the winner. Because the last point is always won by the winner.So this should be just done in O(1).
This is the link to my solution:
https://www.codechef.com/viewsolution/30266292

1 Like

i didnt understand this question. can anyone explain me this question in easy way??

Simple and easy c++ solution

int main() {

int t;
string s;
cin>>t;
while (t--)
{
	cin>>s;
	int zeroes=0,ones=0;
	bool flag = false;
	int index=0;
	while (index<s.length())
	{
		if (s[index]=='0') zeroes++;
		else ones++;
		if (ones>10 && ones-zeroes>=2)
	    {
	       flag=true; break;
		}
		index++;
	}
	if (flag) cout<<"WIN\n";
	else cout<<"LOSE\n";
}

return 0;

}

2 Likes

test cases (1010101010101010101011000), is invalid according to problem

it can be only till 1010101010101010101011
as the chef points are 12, opponents pts are 10
and 12-10 = 2 pts lead for chef [ at the end of the 22nd match ]
GAME OVER !
no need to play those extra 3 match as the winner is already declared.

I don’t understand why editorialist @ Kevin Atienza say “The last match is won by the overall winner of the contest.” where it is given in problem statement man?
Kindly please solve my doubt.

1010101010101010101010
then why output is “LOSS” ?

https://www.codechef.com/viewsolution/46614465
this is my solution…can anyone help where i am wrong?
@iscsi ?
i think i have taken every case given in question

my opinion bhaii
@ketul22_12 bhai aapka input pe last 2 digits ke phle dono ke score becomes 10 and 10
to ab 2 consecutive win chahiye kisi ek user ke liye…your input is not a valid case according to question

Maybe try with this input:
1
111111111100000000000111

@iscsi
i got WIN as answer
and i think it is correct…any other test case??

What about this one?
1
11111111110000000000011000