codeforces Restore Cube(暴力枚举)
Codeforces 枚举 暴力 cube Restore
2023-09-14 08:57:55 时间
/* 题意:给出立方体的每个顶点的坐标(是由源坐标三个数某几个数被交换之后得到的!), 问是否可以还原出一个立方体的坐标,注意这一句话: The numbers in the i-th output line must be a permutation of the numbers in i-th input line! 我们只要对输入的每一行数据进行枚举每一个排列, 然后检查时候能构成立方体就好了! 检查立方体:找到最小的边长的长度 l, 统计边长为l, sqrt(2)*l, sqrt(3)*l的边长 条数,如果恰好分别为12, 12, 4那么就是立方体了... #include iostream #include cstdio #include cstring #include algorithm using namespace std; typedef long long LL; LL num[8][3], d[70]; LL dis(int i, int j){ return (num[i][0]-num[j][0])*(num[i][0]-num[j][0]) + (num[i][1]-num[j][1])*(num[i][1]-num[j][1]) + (num[i][2]-num[j][2])*(num[i][2]-num[j][2]);
if(dfs(cur+1)) return true;//得到当前的全排列之后,继续向下寻找 }while(next_permutation(num[cur], num[cur]+3));//枚举这一个行的每一个全排列 return false; int main(){ for(int i=0; i ++i) for(int j=0; j ++j) scanf("%lld", num[i][j]); if(!dfs(0)) printf("NO\n"); return 0; }
The eight queens puzzle is the problem of placing eight chess queens on an 8 8 chessboard so that no two queens threaten each other.
相关文章
- 【Codeforces 1083A】The Fair Nut and the Best Path
- 【Codeforces 644A】Parliament of Berland
- 【CodeForces 574B】Bear and Three Musketeers
- 【Codeforces Round #476 (Div. 2) [Thanks, Telegram!] D】Single-use Stones
- 【Codeforces Round #447 (Div. 2) A】QAQ
- 【Educational Codeforces Round 31 A】Book Reading
- 【27.40%】【codeforces 599D】Spongebob and Squares
- 【33.33%】【codeforces 681D】Gifts by the List
- 【codeforces 787B】Not Afraid
- 【codeforces 509A】Maximum in Table
- 【codeforces 701C】They Are Everywhere
- 【codeforces 190C】STL
- Codeforces 385 C Bear and Prime Numbers
- Codeforces Round #306 (Div. 2) C
- Codeforces Round #277.5 (Div. 2)
- Codeforces #250 (Div. 2) C.The Child and Toy
- Educational Codeforces Round 36 (Rated for Div. 2)