Page 4 of 6
Posted: Sun Jan 28, 2007 4:08 pm
by l314
I have checked out the post that you give me and I try to fixe my code, but I still got P.E.
Below is one of my output case.
I can't find the difference from the simple output of problem 750.
plz help me find out this bug, thank you.
Posted: Sun Jan 28, 2007 5:05 pm
by helloneo
Your program prints some extra blank lines at the begining..
750 P.E
Posted: Thu Apr 05, 2007 2:07 am
by iamthewall
Hi everyone i got P.E on the 8 Queens problem. I sent it a lot of times and i made a lot of modifications. I read al the suggestions of this forum but i didnt figure out the problem. ANy help plz
Thanks
HELP
Posted: Tue Apr 10, 2007 11:59 pm
by iamthewall
Well at least somebody can help me with a sample input and the output?
Posted: Wed Apr 11, 2007 10:39 pm
by Jan
Try the cases...
Input:
Output:
Code: Select all
SOLN COLUMN
# 1 2 3 4 5 6 7 8
1 2 7 3 6 8 5 1 4
2 3 7 2 8 6 4 1 5
3 4 2 7 3 6 8 1 5
4 4 7 3 8 2 5 1 6
5 5 2 4 6 8 3 1 7
6 6 3 7 2 4 8 1 5
7 6 3 7 2 8 5 1 4
8 6 4 2 8 5 7 1 3
SOLN COLUMN
# 1 2 3 4 5 6 7 8
1 1 5 8 6 3 7 2 4
2 1 6 8 3 7 4 2 5
3 2 6 8 3 1 4 7 5
4 3 5 8 4 1 7 2 6
5 3 6 8 1 4 7 5 2
6 3 6 8 1 5 7 2 4
7 3 6 8 2 4 1 7 5
8 4 2 8 5 7 1 3 6
9 4 2 8 6 1 3 5 7
10 4 6 8 2 7 1 3 5
11 4 6 8 3 1 7 5 2
12 5 1 8 4 2 7 3 6
13 5 1 8 6 3 7 2 4
14 5 2 8 1 4 7 3 6
15 5 3 8 4 7 1 6 2
16 7 3 8 2 5 1 6 4
Hope these help.
Posted: Thu Apr 12, 2007 12:39 am
by ExUCI
Dude your algorithm is fine, but you made a lot mistakes printing the output, here is the list:
- An extra space at the end of every line except the second one.
- Change \t for spaces
- The empty line is between datasets, not at the end of every dataset
That's all, remove your code after AC
Posted: Thu Apr 19, 2007 10:20 pm
by iamthewall
Thx .. finally i did it
Posted: Sat Jun 02, 2007 2:20 am
by soddy
PE means u did not output in the format as u shld hv been....there is no mistake in ur code.....chk out the other threads for dis issue
Thanks Jan...
Posted: Thu Jun 28, 2007 9:03 am
by nymo
Your sample IO helps... the problem was with the sequence number of the solution... I did terrible things and modifications... but didn't understand the correct format... output format is a little hazy.
Posted: Sat Nov 17, 2007 11:19 am
by Iffat
I got WA for this code...

I test all test cases and they r ok with my code..... pls help..
thanx in advance

Posted: Sat Nov 17, 2007 8:07 pm
by Jan
There should be a blank line between cases. Your code cant handle that perfectly. Check your output carefully by saving the output in a file. Hope that helps.
Posted: Thu Nov 22, 2007 7:18 am
by Iffat
AC
thanx jan....it really helps nd i have also edited the array size...
Posted: Sun Feb 03, 2008 9:40 pm
by Saul Hidalgo
Thanks for the input. I got AC.

PE : 750 - 8 Queens Chess Problem
Posted: Mon Jun 09, 2008 6:41 am
by mukit
Hi , I'm getting PE. I read all post before and all tried all ways.
Please help.
Code: Select all
#include<iostream>
#include<iomanip>
using namespace std;
int fres,hash,chess[11][11],input[11][11]={0},colset[11],l_diag[20],r_diag[20];
int res[11],row,col;
void backTrack(int r)
{
int c,m,n,tmax;
if(r==9)
{
for(int i=1;i<=8;i++)
{
if(i==col && res[i]==row)
{
hash++;
cout<<" "<<hash<<" ";
for(int j=1;j<=8;j++)
{
cout<<" "<<res[j];
}
cout<<endl;
break;
}
}
if(fres<tmax)
{
fres=tmax;
}
return;
}
for(c=1;c<=8;c++)
{
if(chess[r][c]==0 && colset[c]==0 && l_diag[r+c]==0 && r_diag[r-c+8]==0)
{
chess[r][c]=1;
colset[c]=1;
l_diag[r+c]=1;
r_diag[r-c+8]=1;
res[r]=c;
backTrack(r+1);
chess[r][c]=0;
colset[c]=0;
l_diag[r+c]=0;
r_diag[r-c+8]=0;
}
}
return;
}
int main()
{
int a;
while(cin>>a)
{
fres=0;
for(int x=1;x<=a;x++)
{
cin>>row>>col;
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{
chess[i][j]=0;
}
colset[i]=0;
}
for(int i=0;i<=20;i++)
{
l_diag[i]=0;
r_diag[i]=0;
}
cout<<"SOLN COLUMN"<<endl;
cout<<" # 1 2 3 4 5 6 7 8"<<endl<<endl;
hash=0;
backTrack(1);
if(x!=a)
{
cout<<endl;
}
}
}
return 0;
}
Re: 750 - 8 Queens Chess Problem
Posted: Wed Jun 11, 2008 9:21 am
by n_arun89
thanks
removed after AC
