195 - Anagram

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

mmonish
Experienced poster
Posts: 109
Joined: Sun Mar 11, 2007 2:55 pm
Location: SUST

Post by mmonish » Sat May 26, 2007 3:24 am

Try this case

Code: Select all

Input
1
abAB

Output
AaBb
AabB
ABab
ABba
AbaB
AbBa
aABb
aAbB
aBAb
aBbA
abAB
abBA
BAab
BAba
BaAb
BabA
BbAa
BbaA
bAaB
bABa
baAB
baBA
bBAa
bBaA
Hope it helps.

SARKAR
New poster
Posts: 21
Joined: Tue May 22, 2007 4:18 pm

Post by SARKAR » Sat May 26, 2007 7:28 am

thnksss mmonish
lthr was some conceptual error :(

but thn also this code produced correct output for most cases......

lolzzzzzzzzz
it even got AC for successor problem (146).....
lucky meee......:lol:



lolzzzzzzzzzzzzzzz

nywaysss thnksss

I FINALLY GOT AC :lol:

mmonish
Experienced poster
Posts: 109
Joined: Sun Mar 11, 2007 2:55 pm
Location: SUST

Post by mmonish » Sat May 26, 2007 1:24 pm

>>SARKAR
U should remove ur code. Otherwise SPOILERS can take the chance.

RC's
Learning poster
Posts: 65
Joined: Fri Jul 13, 2007 3:17 pm

Post by RC's » Sat Jul 14, 2007 8:23 am

I test mmonish case and my program produces right answer. But when I submitted to the OJ, it was RE .

It said :
Your program has died with signal 25 (SIGXFSZ). Meaning:

File size limit exceeded

Does anyone know why this happen ?

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Sat Jul 14, 2007 8:44 am

Usually SIGXFSZ means the same thing as "Output Limit Exceeded" - your program outputs a huge amount of data without stopping.

RC's
Learning poster
Posts: 65
Joined: Fri Jul 13, 2007 3:17 pm

Post by RC's » Sat Jul 14, 2007 9:16 am

Ok then... now I got presentation error. Is there any special format for this problem ? To print the answer, i use the syntax

Code: Select all

printf("%s\n", words);
does it wrong ?

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Sat Jul 14, 2007 9:33 am

It should be fine.

RC's
Learning poster
Posts: 65
Joined: Fri Jul 13, 2007 3:17 pm

Post by RC's » Sun Jul 15, 2007 5:46 am

I think so..
But I've tried six times and still get PE.

Here is my code

Code: Select all

removed.. Get AC already
I asked my friends who has solved his problem and I compared the output files for our program, and it was identical. From the size of our files, it is exactly the same. Could anyone help me ?
Last edited by RC's on Sun Jul 15, 2007 11:18 am, edited 1 time in total.

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Sun Jul 15, 2007 6:22 am

Why is hierarki['z']=21 in your code? Shouldn't it be 52?

RC's
Learning poster
Posts: 65
Joined: Fri Jul 13, 2007 3:17 pm

Post by RC's » Sun Jul 15, 2007 11:19 am

Thanks a lot. It was my fault.
But i still don't understand why it got PE, not WA...
I think it should be WA.

By the way, thank you very much.

ishtiaq ahmed
Learning poster
Posts: 53
Joined: Sat Jul 29, 2006 7:33 am
Location: (CSE,DU), Dhaka,Bangladesh

195[TLE]

Post by ishtiaq ahmed » Mon Aug 27, 2007 9:09 am

I am facing TLE. Ca anybosy help me? Here is my code

Code: Select all

//  Anagram 195


#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	int cas_no,k,length ,i ,j;
	char input[10000] , temp , temp_i , temp_j;
	scanf("%d",&cas_no);
	for(k=0;k<cas_no;k++)
	{
		scanf("%s",input);
		length = strlen(input);
		for(i=0;i<length-1;i++)
			for(j = i + 1 ; j < length ; j++)	
			{
				temp_i = input[i];
				temp_j = input[j];
				if( ( temp_i >= 'a' ) && ( temp_i <= 'z') )
					temp_i -= 31 ;
				if( ( temp_j >= 'a' ) && ( temp_j <= 'z') )
					temp_j -= 31 ;
				if(temp_i>temp_j)
				{
					temp = input[i];
					input[i] = input[j];
					input[j] = temp;
				}
			}
		do 
		{
			puts(input);

		}while( next_permutation( input , input + length) );
	}


	return 0;
}
Waiting for your reply
No venture no gain

with best regards
------------------------
ishtiaq ahmed

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

Post by Jan » Tue Aug 28, 2007 1:50 pm

Try the case.

Input:

Code: Select all

1
ABab
Output:

Code: Select all

AaBb
AabB
ABab
ABba
AbaB
AbBa
aABb
aAbB
aBAb
aBbA
abAB
abBA
BAab
BAba
BaAb
BabA
BbAa
BbaA
bAaB
bABa
baAB
baBA
bBAa
bBaA
I think you havent understood the problem correctly. And use 'input[100]'.

Hope these help.
Ami ekhono shopno dekhi...
HomePage

fR0D
New poster
Posts: 29
Joined: Mon Feb 11, 2008 5:59 am
Contact:

Post by fR0D » Mon Feb 25, 2008 5:05 pm

Can somebody please tell me how to make a compare function for next_permutation..

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Mon Feb 25, 2008 5:37 pm

Code: Select all

struct cmp {
  bool operator()(int x, int y) {
    return x < y;   // replace this with your predicate
  }
};
...
next_permutation(...., cmp());

Brainless
New poster
Posts: 11
Joined: Sat Dec 29, 2007 2:39 pm

Re: 195: anagram, wrong answer

Post by Brainless » Tue Jun 17, 2008 6:13 pm

Hi,

I didn't checked your code, but did you test input with 'z' and 'Z' ?

I've got the same problem and solved it like that ...

Regards,

Brainless

Post Reply

Return to “Volume 1 (100-199)”