You are not logged in. Please login at www.codechef.com to post your questions!

×

Please help me with this code (TTENIS)

Here is my code: Solution
The expected output is also produced and the limits of the variables is also satisfied. The output format is also correct. Is it that we don't have to print leading zeros? Please help me with the code.
Thanks a lot!

asked 12 Oct, 23:27

arnavvarshney's gravatar image

2★arnavvarshney
585
accept rate: 20%


If last character of string is 1 then chef wins

Here is an easy soln for it

You can look at the editorial for full detail

https://discuss.codechef.com/questions/71404/ttenis-editorial

#include<bits/stdc++.h>
using namespace std;
int main() 
{
    int t;    
    cin>>t;    
    while (t--)    
    {    
        string s;    
        cin >> s;    
        cout << (s[s.length()-1] == '1' ? "WIN\n" : "LOSE\n");    
    }
}
link

answered 13 Oct, 01:28

spp____'s gravatar image

2★spp____
1.1k110
accept rate: 8%

edited 13 Oct, 09:58

vijju123's gravatar image

4★vijju123 ♦
11.3k1316

Dear, please read input constraints explicitly. The length of string (i.e. number of matches) can be upto 100.

So your if-else conditions-

if(chef==10&&opp==10)
                    flag=true;
                else if(chef==11&&opp<11&&!flag)
                    System.out.println("WIN");
                else if(opp==11&&chef<11&&!flag)
                    System.out.println("LOSE");

Will all malfunction. I think your code would print nothing for cases when S~100, although I didnt check that.

link

answered 13 Oct, 10:05

vijju123's gravatar image

4★vijju123 ♦
11.3k1316
accept rate: 18%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,064
×443
×1

question asked: 12 Oct, 23:27

question was seen: 92 times

last updated: 13 Oct, 10:05