[思维]CodeForces 135B
2015-05-24 22:13
267 查看
题意:
给出8个点,问能否分成两个集合,使得一个组成正方形,另一个组成矩形。如果能,就输出YES,并且输出两个集合分别是什么,如果能,那就直接输出NO;
分析:
本来觉得这题很烦,没什么兴趣做了,浏览status的时候,偶然发现某final爷的id,点进去亮瞎了双眼。。。代码精简美观,思路一样很暴力,但是暴力的漂亮,于是乎学习了一下。
思路就是判断所有的边的可能排列,然后根据边判断,不用什么点积来做了。亲测正常点的做法起码要100++,细节错误的话还容易WA。这样暴力的话就不用烦恼这些了。
给出8个点,问能否分成两个集合,使得一个组成正方形,另一个组成矩形。如果能,就输出YES,并且输出两个集合分别是什么,如果能,那就直接输出NO;
分析:
本来觉得这题很烦,没什么兴趣做了,浏览status的时候,偶然发现某final爷的id,点进去亮瞎了双眼。。。代码精简美观,思路一样很暴力,但是暴力的漂亮,于是乎学习了一下。
思路就是判断所有的边的可能排列,然后根据边判断,不用什么点积来做了。亲测正常点的做法起码要100++,细节错误的话还容易WA。这样暴力的话就不用烦恼这些了。
[code]#include <cstdio> #include <cstring> #include <cmath> #include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #define read freopen("q.in","r",stdin) #define LL long long #define maxn 1000005 using namespace std; int p[]={0,1,2,3,4,5,6,7,8}; int x[9],y[9]; int d(int a,int b) { return (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]); } int main() { // read; int i,j; for(i=1;i<=8;i++)scanf("%d%d",&x[i],&y[i]); do { if(d(p[1],p[2])==d(p[2],p[3]) && d(p[2],p[3])==d(p[3],p[4]) && d(p[3],p[4])==d(p[4],p[1]) && d(p[1],p[3])==d(p[4],p[2]) && d(p[5],p[6])==d(p[7],p[8]) && d(p[5],p[8])==d(p[6],p[7]) && d(p[5],p[7])==d(p[6],p[8])) { return printf("YES\n%d %d %d %d\n%d %d %d %d\n",p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8]),0; } }while(next_permutation(p+1,p+9)); puts("NO"); return 0; }
相关文章推荐
- CodeForces - 672D Robin Hood (思维二分)
- CodeForces - 611B 数学思维
- Codeforces 672D Robin Hood 二分判定+思维
- Codeforces 810C Do you want a date?【思维】
- 【CodeForces - 919E】 Congruence Equation 【费马小定理 + 思维】
- 【Codeforces 747 C Servers 】+ 思维 或 优先队列
- CodeForces 552C. Vanya and Scales(进制+思维)
- codeforces 814D An overnight dance in discotheque(几何思维)
- Codeforces 272D Dima and Two Sequences【思维+模拟】
- CodeForces 567B Berland National Library【思维】
- DFS(思维) CodeForces - 525D Arthur and Walls
- 【组合数学思维】CodeForces - 233C Cycles
- Codeforces 509E(思维)
- Codeforces 758C Unfair Poll 【数学】【思维】
- CodeForces - 859B Lazy Security Guard(思维)
- codeforces 705 B. Spider Man (思维)
- Codeforces 340E Iahub and Permutations【思维+错排Dp】
- CodeForces 626D Jerry's Protest+思维题
- Codeforces 673B Problems for Round【思维】
- Codeforces 635B Island Puzzle【最小表示法+思维】