"If more than one order of brown, green, and clear bins yields the minimum number of movements then the alphabetically first string representing a minimal configuration should be printed."
try this input:
2 3 1 5 3 1 3 5 3
the expected output is:
CBG 15
your output:
GBC 15
Both CBG & GBC needs 15 moves , but since CBG is "first" compared to GBC (C is earlier than G) , you should output "CBG".
looking at your code, it seems that your order of evaluation is :
BCG , BGC , GCB , GBC , CGB, CBG.
Thank you for your help and time u've spent to find the bug. Unfortunately I don't have much time now to ultimately deal with this problem, but I'll do it soon . And I'll post about the result ...
Wirjawan - debug master
BTW: I'd like to thank A1 for his good intentions:-)
If you are using a mail agent to submit problems it can cut off the lines that are painfully long(for it) so only a portion of your code goes in to the judge.
You should have a copy of the code *submitted* to the judge in the judge response in your mailbox(if you didnt delete that already).Go check it and it should tell you more where exactly the error is.
min=movements[0].n;
for( i=1 ; i<6 ; i++ )
if(movements[i].n<min)
min=movements[i].n;
for( i=0 ; i<6 ; i++ )
if(movements[i].n==min)
{
cout<<movements[i].s<<" "<<min<<endl;
break;
}
}
return 0;
}
here's my corrected prog, why's it wa? i've almost tried every test datas i could get...
i did adhere to the output specification that the output should be in lexicographical order, is there sth else i may neglect?
for example , http://acm.uva.es/p/v1/102.html
in this Q, how many lines should i process??
is there any limit??
if there is no limit, how can i process all the lines if the line number exceeds the limit of array of the compiler?
Try processing the test cases one by one instead of reading the whole input into memory first. The task 102 can be solved with O(1) memory, i.e. the memory your program uses doesn't depend on the size of the input.
As a side note, when using 32-bit compilers you can make pretty huge arrays
for(j=0;j<3;j++)
{
maxbin[final[j]]=binname[j];
printf("for %c, max is %d, value is %d\n",binname[j],final[j],bin[final[j]*3+j]);
printf("%c %c\n",maxbin[final[j]],binname[j]);
for(i=0;i<3;i++)
if(i!=final[j]){printf("total: %d add: %d\n",total,bin[i*3+j]);
total+=bin[i*3+j];}
}