Page 2 of 2

Posted: Sun Oct 31, 2004 12:35 pm
by eg_frx
What is wrong with my code??????!?!?!?!!!!!!!

My code generates exactly the same result as the 'correct one' above, but got WA!!

Why?!

Grateful for any help! Thanks
[cpp]
#include <iostream>
#include <algorithm>
using namespace std;

void main(){
int route[7] = {2, 3, 1, 5, 3, 4, 5};
int process;

bool edges[21];
do{
edges[2] = 0;
edges[6] = 0;
edges[3] = 0;
edges[15] = 0;
edges[12] = 0;
edges[10] = 0;
edges[5] = 0;
edges[20] = 0;

process = route[0];
if (edges[process])
continue;
else
edges[process] = 1;

process = route[0] * route[1];
if (edges[process])
continue;
else
edges[process] = 1;

process = route[1] * route[2];
if (edges[process])
continue;
else
edges[process] = 1;

process = route[2] * route[3];
if (edges[process])
continue;
else
edges[process] = 1;

process = route[3] * route[4];
if (edges[process])
continue;
else
edges[process] = 1;

process = route[4] * route[5];
if (edges[process])
continue;
else
edges[process] = 1;

process = route[5] * route[6];
if (edges[process])
continue;
else
edges[process] = 1;

process = route[6] * 2;
if (edges[process])
continue;
else
edges[process] = 1;

cout << 1;
for (int i = 0; i < 7; i++)
cout << route;
cout << 2 << endl;

} while (next_permutation(route, route + 7));

}
[/cpp]

Posted: Wed Nov 10, 2004 2:40 am
by eg_frx
help!

Posted: Mon Sep 25, 2006 5:47 am
by Raiyan Kamal
malf's post here is a spoiler, REQUESTING MODERATOR'S ATTENTION

Re: 291 WA

Posted: Sat Aug 16, 2008 3:49 am
by kbr_iut
if u try to solve it with next_permutation u only have to do two things over each permutation-----

1.check whether it is possible to reach from each element to next element of that permutation or not.
2.check whether one edge overlaps other edge or not.
if u r still getting WA.let me know i will send u the pseudocode over pm.
although,,,better if u solve it with backtrack.
hope it will help.

Re: 291 WA

Posted: Sat Jul 25, 2009 10:19 am
by lnr
Output from AC code:

Code: Select all

123153452
123154352
123451352
123453152
123513452
123543152
125134532
125135432
125315432
125345132
125431532
125435132
132153452
132154352
132534512
132543512
134512352
134512532
134521532
134523512
134532152
134532512
135123452
135125432
135215432
135234512
135432152
135432512
152134532
152135432
152345312
152354312
153123452
153125432
153213452
153254312
153452132
153452312
154312352
154312532
154321352
154325312
154352132
154352312