习题5-6 对称轴 UVA1595
来源:互联网 发布:联通4g网络接入点设置 编辑:程序博客网 时间:2024/04/30 04:44
#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int MAX=100000000;
//用一个vector到int的字典来存储所有的点,y值作为Key,相同y值的点被存入同一个vector里。
//判断时,先计算第一个key值下的所有数的平均值,然后将之后的Key值下的平均值与它比较,只要有一个不相同则输出NO。
//全相同则输出YES
int main()
{
int N;
cin>>N;
while(N--)
{
map<int,vector<int>> points;
int M;
cin>>M;
while(M--)
{
int x;
cin>>x;
int y;
cin>>y;
points[y].push_back(x);
}
bool istrue=1;
bool first=1;
double sum=0;
double avr=0;
for(map<int,vector<int>>::iterator it=points.begin();it!=points.end();it++)
{
if(first)
{
for(int i=0;i!=(*it).second.size();i++)
{
sum+=(*it).second[i];
}
first=0;
avr=sum/((*it).second.size());
}
else
{
double tempsum=0;
double tempavr=0;
for(int i=0;i!=(*it).second.size();i++)
{
tempsum+=(*it).second[i];
}
tempavr=tempsum/((*it).second.size());
if(tempavr!=avr)
{
istrue=0;
break;
}
}
}
if(istrue==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
0 0
- 习题5-6 对称轴 UVa1595
- 习题5-6 对称轴 UVA1595
- 习题5-6 对称轴(Symmetry, UVa1595)
- 算法竞赛入门经典 第二版 习题5-6 对称轴 Symmetry uva1595
- 算法竞赛入门经典(第2版)习题5-6 对称轴(Symmetry) Uva1595
- UVA1595-对称轴
- UVA1595(对称轴)
- 紫书习题5-6 uva1595
- Uva1595 Symmetry 【set集合】【习题5-6】
- uva1595对称轴 STL模拟
- uva1595 Symmetry 习题5-6 (用结构体解决)
- 关于"对称轴 (Symmetry, ACM/ICPC Seoul 2004, UVa1595"的讨论
- 5-6 UVA 1595 Symmetry对称轴
- 对称轴
- 章五习题六 对称轴 Symmetry (map,vector)
- [刷题]算法竞赛入门经典(第2版) 5-6/UVa1595 - Symmetry
- UVa1595 - Symmetry
- UVa1595 - Symmetry
- SSH框架遇到的问题
- 运行jar包找不到依赖包的解决方法
- Multi-class Classification相关
- Android爱读app开发记录之三---皮肤更换
- Java 多线程拷贝文件夹并调用tinyPng算法接口压缩图片实现(生产消费变种)
- 习题5-6 对称轴 UVA1595
- bash基础功能之历史命令和命令补全
- 输出日历
- nginx 414 Request-URI Too Large
- SylixOS下移植C++程序——命名粉碎
- Python3.XX---网络编程
- android 开发百度地图遇到的问题
- 数据结构实验之二叉树七:叶子问题
- 用request获取form标签乱码问题