博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Kattis之旅——Eight Queens
阅读量:4583 次
发布时间:2019-06-09

本文共 1804 字,大约阅读时间需要 6 分钟。

In the game of chess, the queen is a powerful piece. It can attack by moving any number of spaces in its current row, in its column or diagonally.

In the eight queens puzzle, eight queens must be placed on a standard 8×8

chess board so that no queen can attack another. The center figure below shows an invalid solution; two queens can attack each other diagonally. The figure on the right shows a valid solution. Given a description of a chess board, your job is to determine whether or not it represents a valid solution to the eight queens puzzle.

\includegraphics[width=0.7\textwidth ]{chess}
Figure 1: Queen movement (left), invalid solution (center), valid solution (right).

Input

Input will contain a description of a single chess board, given as eight lines of eight characters each. Input lines will consist of only the characters ‘.’ and ‘*’. The ‘.’ character represents an empty space on the board, and the ‘*’ character represents a queen.

Output

Print a single line of output. Print the word “valid” if the given chess board is a valid solution to the eight queens problem. Otherwise, print “invalid”.

Sample Input 1 Sample Output 1
*.........*.........*.........*..*.............*.....*.....*....
invalid
Sample Input 2 Sample Output 2
*.............*.....*..........*.*.........*.........*....*.....
valid

给出一个图,判断是否符合8皇后的摆法。

题目很简单,自己错的一塌糊涂。

#include 
using namespace std;struct point{
  int x,y; }; int absolutey(int z) { if(z<0){
return z*-1;} else{
return z;}} bool ceksinggung(point a, point b) { if(a.x==b.x||a.y==b.y||(a.x+a.y)==(b.x+b.y)||(a.x-a.y)==(b.x-b.y)||(a.y-a.x)==(b.y-b.x)) return true; else return false;}int main() { vector
vp; for(int i=0;i<8;i++) { string s; cin>>s; for(int j=0;j

 

转载于:https://www.cnblogs.com/Asimple/p/6744635.html

你可能感兴趣的文章
利用putty的pscp命令上传文件
查看>>
读《世界是数字的》有感
查看>>
Git使用
查看>>
Linux下新手常用命令
查看>>
一个小证明
查看>>
tesseract 图片识别文字
查看>>
(转)java二维数组的深度学习(静态与动态)
查看>>
functor
查看>>
偏导数
查看>>
java的swing设置弹出保存文件窗口
查看>>
深入学习 viewport 和 px
查看>>
【noip模拟】2048
查看>>
Vue+Webpack配置css-loader时报错:Module build failed: Unknown word
查看>>
[AHOI2001]多项式乘法
查看>>
C#中的线程(二) 线程同步基础
查看>>
mongo-mapreduce测试(6)——综合测试
查看>>
Linux 批量删除文件的方法
查看>>
Android开源项目发现--- 工具类向下兼容篇(持续更新)
查看>>
零碎笔记之内存机制
查看>>
博客导览
查看>>