Why do I get Wrong Answer?

,

Can you please give me your submission link or your code so I can see what is wrong.

@sarthak1308 Your Code:

#include<iostream>
using namespace std;
int main()
{
	int t;
	cin>>t;
	if((t>=1)&&(t<=1000))
	{
		for(int i=0; i<t; i++)
		{
		int num,rnum=0;
		cin>>num;
		if((num>=1)&&(num<=100000))
		{
			while(num!=0)
			{
				int b=num%10;
				num=num/10;
				rnum=rnum*10+b;
			}
			cout<<rnum<<endl;
		}
	    }
	}
}

How is it affecting the logic…?
i got your point, it should be that way (more professional but logic…?)

Still it is throwing wrong output…

This change really shouldn’t make any difference - can you give a testcase where it does?

I can’t see anything wrong with @sarthak1308’s solution at all, provided that the constraints are correct, which they often aren’t.

@sarthak1308 - try removing the if((t>=1)&&(t<=1000)) and if((num>=1)&&(num<=100000)) checks (they are not needed anyway). Then submit, and post a link to your submission here.

@vijju123 / @admin - can we get the constraints/ testcases fixed for this Problem?

Thanks to @aryan12 for confirming :slight_smile:

4 Likes

Gotcha! You have to remove the Constraints part.
Here my solution:

#include<iostream>
using namespace std;
int main()
{
	int t;
	cin>>t;
	if((t>=1)&&(t<=1000))
	{
		for(int i=0; i<t; i++)
		{
		int num,rnum=0;
		cin>>num;
			while(num>=10)
			{
				int b=num%10;
				rnum=rnum*10+b;
				num=num/10;
			}
			rnum=rnum*10+num;
			cout<<rnum<<endl;
		}
	}
}
1 Like

I don’t know, but I have just removed these two lines and I have got AC

2 lines I have removed

if((t>=1)&&(t<=1000))

if((num>=1)&&(num<=100000))

2 Likes

Shit! After I understand it and post my code for help, I saw @ssjgz already post this.

2 Likes

Thank you so much…its working after i removed the constraints…

3 Likes

The test file have N \leq 10^6. I have modified the statement. :slight_smile:

2 Likes

Great, thanks for the rapid fix :slight_smile:

1 Like

Lead game problem
Can you help me out here with whats wrong…Wrong answer error
#include
using namespace std;
int main()
{
int T;
int alead=0,blead=0;
cin>>T;
if (T<=1000)
{
for (int i=0; i<T; i++)
{
int ascore,bscore;
cin>>ascore>>bscore;
if (ascore>bscore)
{
if((ascore-bscore)>alead)
alead=ascore-bscore;
}
else if (bscore>ascore)
{
if((bscore-ascore)>blead)
blead=bscore-ascore;
}
}
if(alead>blead)
cout<<1<<" “<<alead;
else if(blead>alead)
cout<<2<<” "<<blead;
}
}

Copy-and-paste:

Please either format your code or (better!) link to your submission :slight_smile:

https://www.codechef.com/viewsolution/30076934

1 Like

Thanks - it fails on the same testcase as this guy’s.

1 Like

Can you tell me whats wrong?

That’s not a correct link to your code :slight_smile:

1 Like

https://www.codechef.com/viewsolution/30367056

1 Like

This gives the wrong answer for the testcase:

9
3 66
3 20
2 60
2 1
1 69
3 66
3 1
3 72
1 54

(the answer should be

2 388

)

1 Like