Test instructions began to fully understand the mistake,,, that is to give a Queen's position to ask a few steps can let them in peace
In fact, it is the beginning of peace, how many ways to change the position of three queens and still be peaceful?
Can think of all the Queen's horizontal axis is 1 to N, the ordinate is 1 to n,,,,, so three Empress transform, actually is to change three Queen's horizontal axis ordinate to see can ...
There are no things on the diagonal.
Code from others: http://blog.sina.com.cn/s/blog_5f50d0c20100d5hn.html
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace Std;
#include <stdio.h>
Long H[200];long N;
void swap (Long a,long b,long c)
{long t1=h[a],t2=h[b],t3=h[c]; h[b]=t1; h[c]=t2; h[a]=t3;}
BOOL KS ()
{bool A[200]={false},b[200]={false};
for (int i=1;i<=n;i++)
{if (a[i+h[i]+100]==true) return false; if (b[i-h[i]+100]==true) return false; A[i+h[i]+100]=true; B[i-h[i]+100]=true; } return true;
int main () {long x, y; scanf ("%ld", &n);
for (long i=1;i<=n;i++) {scanf ("%ld%ld", &x,&y); H[x]=y; }
Long i,j,k,s=0; for (i=1;i<=n;i++) for (j=1;j<i;j++) for (k=1;k<j;k++)
{swap (I,J,K); if (KS () ==true) s++; Swap (I,J,K); if (KS () ==true) s++; Swap (I,J,K); }
printf ("%ld\n", s); return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
URAL 1034. Queens in peaceful positions