UVa 1595 解题报告
来源:互联网 发布:q20 软件 编辑:程序博客网 时间:2024/05/21 06:53
运用 map 将随机的行数转换为按照第一次输入的顺序进行转换,不会影响对称性,而且方便存储。
#include <bits/stdc++.h>
using namespace std;
double findsym(vector <int>v, int cnt)
{
int tot = 0;
for (int i = 0; i < cnt; ++i)
tot += v[i];
if(tot != 0)return tot / cnt;
else return 0;
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T;
cin >> T;
while(T--){
int n;
cin >> n;
map<int ,int>line;
vector <int>col[1005];
for (int i = 1; i <= n; ++i)
{
int x,y;
cin >> x >> y;
if(line[y]==0)
line[y] = i;
col[line[y]].push_back(x);
/*int t;
t = col[line[y]].size();
cout << t << endl;*/
}
double sym = 100000;
int ok = 1;
for (int i = 1; i <= n; ++i)
{
int y = col[i].size(),t;
//cout << y <<endl;
if(sym < 100000.0001 && sym > 99999.9999 && y > 0)
sym = findsym(col[i], y);
else if(sym < 90000 && y >0){
t = findsym(col[i], y);
if((t - sym) > 0.001 || (sym - t) > 0.001){
ok = 0;
break;
}
}
}
if(ok)cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}
原题如下:
The gure shown on the left is left-right symmetric as it is possible to fold the sheet of paper along a
vertical line, drawn as a dashed line, and to cut the gure into two identical halves. The gure on the
right is not left-right symmetric as it is impossible to nd such a vertical line.
Write a program that determines whether a gure, drawn with dots, is left-right symmetric or not.
The dots are all distinct.
Input
The input consists of T test cases. The number of test cases T is given in the rst line of the input le.
The rst line of each test case contains an integer N, where N (1 N 1; 000) is the number of dots
in a gure. Each of the following N lines contains the x-coordinate and y-coordinate of a dot. Both
x-coordinates and y-coordinates are integers between
- UVa 1595 解题报告
- UVA 10878 解题报告
- UVA 10815 解题报告
- UVA 10010 解题报告
- UVA 10115 解题报告
- UVA 10361 解题报告
- UVA 537 解题报告
- UVA 409 解题报告
- UVA 644 解题报告
- UVA 10494 解题报告
- UVA 424 解题报告
- UVA 10106 解题报告
- UVA 10420 解题报告
- UVA 10474 解题报告
- UVA 152 解题报告
- UVA 299 解题报告
- UVA 755 解题报告
- UVA 156 解题报告
- 摄影测量后方交会MATLAB
- S5PV210的启动过程概述
- 使用Xen-tools工具建Pv domain
- Linux下 环境变量/etc/profile、/etc/bashrc、~/.bashrc的区别
- 4.安装mysql服务及QB的使用
- UVa 1595 解题报告
- 找规律填数字
- java类加载
- 给第三方没有加密的dll强打签名
- Framework7跳转页面如何自动隐藏工具栏(no-tabbar)
- hive-site.xml
- s3c6410时钟体系
- MAC终端命令自动补全
- 快速排序总结