i've repair my coding earlier where it was runtime error.
now i'm facing with WA. i'm sure my output is not wrong. you can try my output with my c source code :
thx for the help. i've fixed it like this in prototype link buat_awal
else{ if(c->z!=t->z) { t->next=c; t=c; } }
it answered aabcd like abcd. But it's still wrong answer
i hope you can find my fault. BTW thanks adil
I know I could use the STL, but the problem explicitly asks you for an algorithm to enumerate all permutations, not just use someone else's algorithm, which would render the problem trivial.
My approach to find the next permutation (sigperm function) consists of finding the maximum decreasing sequence ending at the end of a permutation (the sequence is v[i + 1..tamano)), next exchanging v with the smallest element in v[i + 1..tamano) larger than v, and finally reversing v[i + 1..tamano). (The function sigperm returns 0 if the permutation given was the last one in lexicographic order).
The algorithm is correct, and I cannot find any flaws in my implementation, nor test cases for which my program fails.
Your algorithm seems to be correct but the implementation seems to be a little off the track.
Here is a case that gives incorrect output with your code.
input
[c]
1
aabb
[/c]
Your code outputs
[c]
aabb
abba
baba
bbaa
[/c]
I hope you can see the mistake. There should be 6 permutations.
I know I could use the STL, but the problem explicitly asks you for an algorithm to enumerate all permutations, not just use someone else's algorithm, which would render the problem trivial.
Thats very good. You don't like using other people's algorithm.
OOOps... You have used qsort, but I don't see any pivoting/partitioning. Which means its built in.... just kidding.
In real time contests where time is very crucial the usage of built in functions can be very handy. But in 24s I appreciate your steps.
Many thanks for that. I found my mistake --fixing it amounted to writing a <= in place of a <.
As for quicksort... you're right, but then again using it merely helps you with an unimportant part of the problem (as opposed to directly solving it)
Of course in a contest I wouldn't hesitate to use next_perm and all that, but one doesn't get much practice by writing a 10-line program and submitting it to the UVA judge.. And to be honest I haven't used the STL much so far, though I think it could indeed come in handy in contest situations (for instance, I don't believe anyone could afford to code his own heap or balanced-tree routines unless he is prepared to spend the best part of the contest time on a single problem..)
it's about 10098 problem, and every time I submit it gives me that error.
What does it means?. About 10 minutes ago gaved me Time limit exceeded, and now it gives me this, that I understood, but this....., and I;m afraid that I deleted the judje-uva sender from my email.....