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

×

HELP TO EXTRACT MISTAKE

I AM GETTING WRONG ANSWER. QUES LINK-https://www.codechef.com/problems/TICKETS5

#include<stdio.h>
int main()
{
    int T,l,i,j;
    char S[100];
    scanf("%d",&T);
    for(i=0;i<T;i++)
    {
        scanf("%s",&S);
        l=strlen(S);
        for(j=0;j<l-2;j++)
        {
            if(S[j]==S[j+2]&&l%2==0&&S[j]!=S[j+1]&&S[j]>64&&S[j]<91&&l>1)
             {
                if(j==l-3)
                printf("YES\n");
                else
                continue;
             }
            else 
             { 
                printf("NO\n");
                break;
             }
        }
    }
    return 0;
}

asked 20 Jun '17, 20:58

mnjn25's gravatar image

3★mnjn25
272
accept rate: 33%

edited 21 Jun '17, 11:05

vijju123's gravatar image

4★vijju123 ♦♦
15.4k12066


Please provide a properly indented code. The above code also contains lots of "" for no reason

{="" scanf("%s",&s);="" l="strlen(S);" for

Please provide an ideone link or something similar instead of pasting code here.

Also I checked, you have successfully solved the problem : https://www.codechef.com/viewsolution/14300474

You can provide the solution link like this in case of wrong answer as well. These link would be helpful to understand your code.

link

answered 21 Jun '17, 09:45

dragonemperor's gravatar image

3★dragonemperor
89321134
accept rate: 10%

Your code doesnt run at all for S of length 2.

Input
1
AB
Your output
(blank. Nothing printed)
Expected Output
YES

You are doing too much with the conditions. Simplify the thinking. What i suggest, is, that you check that adjacent elements are unequal, and that string has only 2 characters.

link

answered 21 Jun '17, 11:10

vijju123's gravatar image

4★vijju123 ♦♦
15.4k12066
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:

×9

question asked: 20 Jun '17, 20:58

question was seen: 354 times

last updated: 21 Jun '17, 11:10