Page 12 of 17
Posted: Sat May 26, 2007 3:24 am
by mmonish
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.
Posted: Sat May 26, 2007 7:28 am
by SARKAR
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......
lolzzzzzzzzzzzzzzz
nywaysss thnksss
I FINALLY GOT AC
Posted: Sat May 26, 2007 1:24 pm
by mmonish
>>SARKAR
U should remove ur code. Otherwise SPOILERS can take the chance.
Posted: Sat Jul 14, 2007 8:23 am
by RC's
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 ?
Posted: Sat Jul 14, 2007 8:44 am
by mf
Usually SIGXFSZ means the same thing as "Output Limit Exceeded" - your program outputs a huge amount of data without stopping.
Posted: Sat Jul 14, 2007 9:16 am
by RC's
Ok then... now I got presentation error. Is there any special format for this problem ? To print the answer, i use the syntax
does it wrong ?
Posted: Sat Jul 14, 2007 9:33 am
by mf
It should be fine.
Posted: Sun Jul 15, 2007 5:46 am
by RC's
I think so..
But I've tried six times and still get PE.
Here is my code
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 ?
Posted: Sun Jul 15, 2007 6:22 am
by mf
Why is hierarki['z']=21 in your code? Shouldn't it be 52?
Posted: Sun Jul 15, 2007 11:19 am
by RC's
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.
195[TLE]
Posted: Mon Aug 27, 2007 9:09 am
by ishtiaq ahmed
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
Posted: Tue Aug 28, 2007 1:50 pm
by Jan
Try the case.
Input:
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.
Posted: Mon Feb 25, 2008 5:05 pm
by fR0D
Can somebody please tell me how to make a compare function for next_permutation..
Posted: Mon Feb 25, 2008 5:37 pm
by mf
Code: Select all
struct cmp {
bool operator()(int x, int y) {
return x < y; // replace this with your predicate
}
};
...
next_permutation(...., cmp());
Re: 195: anagram, wrong answer
Posted: Tue Jun 17, 2008 6:13 pm
by Brainless
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