标签:
#include<cstdio>using namespace std;struct Point{int x,y;}p[10];int check(int a,int b){if(p[a].x == p[b].x) return 1;if(p[a].y == p[b].y) return 1;if(p[a].x - p[a].y == p[b].x - p[b].y) return 1;if(p[a].x + p[a].y == p[b].x + p[b].y) return 1;return 0;}int main(){int t;scanf("%d",&t);while(t--){char str[10];for(int i = 0 ; i < 8 ; ++i){scanf("%s",str);p[i].x = str[0] - ‘A‘;p[i].y = str[1] - ‘0‘;}int flg = 1;for(int i = 0 ; flg && i < 8 ; ++i){for(int j = i + 1 ;flg && j < 8 ; ++j){if(check(i,j)){flg = 0;}}}puts(flg ? "Valid" : "Invalid");}return 0;}
[2016-04-17][Gym][100947][B][Queens, Again!!]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/88d6475baa3fd7c9dc8fd7c4c984636a.html