146 - ID Codes

All about problems in Volume 1. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Try the cases.

Input:

Code: Select all

aaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaabcaaaaaaaaaaa
#
Output:

Code: Select all

aaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaa
No Successor
aaaaaaaaaaaaaaaaaaaacaaaaaaaaaaab
Hope these help. And if your code passes you can post your code, too. [ Use code tags if you want to post your code ]
Ami ekhono shopno dekhi...
HomePage

newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton »

i am extremely sorry. it was a chilly mistake [spelling mistake]. but it should be WA!
why PE??
Last edited by newton on Sun Jul 22, 2007 2:03 pm, edited 1 time in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Your code doesn't even pass the samples. Check carefully.
Ami ekhono shopno dekhi...
HomePage

masud93
New poster
Posts: 2
Joined: Thu Jul 23, 2009 8:47 pm

Re: 146 ID Codes

Post by masud93 »

I am getting WA.plz check my code.

Code: Select all

#include<stdio.h>
#include<string.h>
int main()
{
	int i,j,temp,f,n,k,m;
	char x[1000],y[]="#";
	while(scanf("%s",x)==1)
	{
		n=strlen(x);
		if(!(strcmp(y,x)))
			break;
		for(i=n-1,f=0;i>0;i--)
		{
			if(x[i]>x[i-1])
			{
				f=1;
				temp=x[i];
				x[i]=x[i-1];
				x[i-1]=temp;
				break;
			}
		}
		if(f==1)
		{
			for(k=0,m=i ;m<n-1;m++,k++ )
			{
				for(j=i;j<n-1-k;j++)
				{
					if(x[j]>x[j+1])
					{
						temp=x[j];
						x[j]=x[j+1];
						x[j+1]=temp;
					}
				}
			}
			puts(x);
		}
		else
			printf("No Successor\n");
	}
	return 0;
}

enamsustcse
New poster
Posts: 9
Joined: Fri May 04, 2012 9:41 pm
Location: SUST, Sylhet, Bangladesh
Contact:

Re:

Post by enamsustcse »

UFP2161 wrote:cxxoc --> occxx
This test case was very helpful for me, Thanks to all belonging to this problem :)
-----
Enamul Hassan,
Student,
2nd year, CSE,
SUST, Sylhet, Bangladesh

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 146 - ID Codes

Post by uDebug »

Added some input to help with testing / debugging here:

http://www.udebug.com/UVa/146
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

Post Reply

Return to “Volume 1 (100-199)”