Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem H. Parallel Worlds 计算几何
Problem H. Parallel Worlds
题目连接:
http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022&all_runs=1&action=140
Description
Alex is a Baisuralen State University student. Alex and BSU live in two parallel worlds. As we know from
school geometry classes, parallel lines do not intersect. However, in reality and unfortunately these two
parallel worlds do intersect.
There are some courses in BSU that came from hell. They make parallel worlds intersect and force Alex
to visit lectures. Or even more, they cause pain and humiliation. (It was once even said, that the other
name for course of ‘Functional Analysis’ (shortly FUN) is ‘Pain and Humiliation’. That is, FUN is not
fun.) For example, once Alex slept during such course, and was woken up by professor’s voice. Afterwards
he was asked if he had moved to Banach Space and was told to move to railway station.
Not everything is so bad, however. There are courses that are from heaven. They are finished in any mark
you want without needing to visit them.
You are requested to provide a procedure to establish that some courses are from heaven. As part of that,
you need to provide two sets of points P and Q on a plane, each containing N points. All points in P
and Q should be distinct, and the intersection of P and Q should be empty. Sets P and Q should satisfy
the following property. There should exist N pairwise nonparallel lines, such that sets of projections of P
and Q on these lines coincide. Of course, the lines should also be provided. Moreover, pairs of points that
coincide are also required.
One can show that for any positive integer N such sets of points exist.
Input
The only line of input contains a single number N (1 ≤ N ≤ 100).
Output
Output 3 × N lines.
First N lines should contain two real numbers x
P
i
y
P
i — coordinates of points in set P.
Next N lines should contain two real numbers x
Q
i
y
Q
i — coordinates of points in set Q.
Afterwards output the descriptions of the lines: three real numbers Ai
, Bi and Ci—coefficients of the ith
line (Aix + Biy + Ci = 0), and a permutation of numbers from 1 to N (qi1, qi2, . . . , qiN ) (the projection of
the first point from P should coincide with the projection of the qi1st point of the set Q, the projection
of the second point from P should coincide with the projection of the qi2nd point of Q and so on).
Absolute value of all numbers should not be greater than 106
.
The distance between any two points from P ∪ Q should be at least 1. And P ∩ Q = ∅.
Two lines are considered parallel if the angle between the lines is less than 10−2
rad., or if the cross
product AiBj − BiAj is less than 10−6
.
Two projections coincide if the distance between them is not greater than 10−6
Sample Input
1
Sample Output
0 0
1 0
1 0 0 1
Hint
题意
让你构造两个点集合,各有n个点,且不相交。
然后你需要构造n条直线
然后需要这俩集合中的点,对于每一条线,都能在直线上面的映射相同。
题解:
看着烧脑子,但实际上构造一个正2n边形就好了。
代码
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
vector<pair<double,double> >P;
vector<pair<double,double> >Q;
/* 基本几何结构 */
struct POINT
{
double x;
double y;
POINT(double a=0, double b=0) { x=a; y=b;} //constructor
};
struct LINESEG
{
POINT s;
POINT e;
LINESEG(POINT a, POINT b) { s=a; e=b;}
LINESEG() { }
};
struct LINE // 直线的解析方程 a*x+b*y+c=0 为统一表示,约定 a >= 0
{
double a;
double b;
double c;
LINE(double d1=1, double d2=-1, double d3=0) {a=d1; b=d2; c=d3;}
};
LINE makeline(POINT p1,POINT p2)
{
LINE tl;
int sign = 1;
tl.a=p2.y-p1.y;
if(tl.a<0)
{
sign = -1;
tl.a=sign*tl.a;
}
tl.b=sign*(p1.x-p2.x);
tl.c=sign*(p1.y*p2.x-p1.x*p2.y);
return tl;
}
vector<LINE>AA;
int mp[105];
int main(){
int n;
scanf("%d",&n);
if(n==1){
printf("0 0\n");
printf("1 0\n");
printf("1 0 0 1\n");
return 0;
}
double len = 10000;
double x = pi/n;
POINT AAA,BBB;
for(int i=0;i<2*n;i++){
double X = len * sin(x*i);
double Y = len * cos(x*i);
if(i%2==0){
P.push_back(make_pair(X,Y));
AAA = POINT(X,Y);
}else{
Q.push_back(make_pair(X,Y));
BBB = POINT(X,Y);
}
if(i>=1&&i<=n){
POINT A,B;
A.x = (AAA.x+BBB.x)/2.0;
A.y = (AAA.y+BBB.y)/2.0;
B.x = 0;
B.y = 0;
AA.push_back(makeline(A,B));
}
}
for(int i=0;i<n;i++)
printf("%.12f %.12f\n",P[i].first,P[i].second);
for(int i=0;i<n;i++)
printf("%.12f %.12f\n",Q[i].first,Q[i].second);
for(int i=0;i<n;i++){
printf("%.12f %.12f %.12f ",AA[i].a,AA[i].b,AA[i].c);
int a1 = i/2,b1 = (i+1)/2;
for(int j=0;j<n;j++){
mp[(a1-j+n)%n] = (b1+j)%n;
}
for(int j=0;j<n;j++)
printf("%d ",mp[j]+1);
printf("\n");
}
}
Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem H. Parallel Worlds 计算几何的更多相关文章
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem K. UTF-8 Decoder 模拟题
Problem K. UTF-8 Decoder 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c702 ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem I. Alien Rectangles 数学
Problem I. Alien Rectangles 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem F. Turning Grille 暴力
Problem F. Turning Grille 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c70 ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem C. Cargo Transportation 暴力
Problem C. Cargo Transportation 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem G. k-palindrome dp
Problem G. k-palindrome 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022 ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem A. A + B
Problem A. A + B 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022&al ...
- 2010 NEERC Western subregional
2010 NEERC Western subregional Problem A. Area and Circumference 题目描述:给定平面上的\(n\)个矩形,求出面积与周长比的最大值. s ...
- 2009-2010 ACM-ICPC, NEERC, Western Subregional Contest
2009-2010 ACM-ICPC, NEERC, Western Subregional Contest 排名 A B C D E F G H I J K L X 1 0 1 1 1 0 1 X ...
- 【GYM101409】2010-2011 ACM-ICPC, NEERC, Western Subregional Contest
A-Area and Circumference 题目大意:在平面上给出$N$个三角形,问周长和面积比的最大值. #include <iostream> #include <algo ...
随机推荐
- hdu 3022 Sum of Digits
http://acm.hdu.edu.cn/showproblem.php?pid=3022 题意: 最多不超过10000组数据,每组数据给定两个数n,m,求一个最小的数,使得该数每一位之和等于n,每 ...
- HTML5+CSS把footer固定在底部
在刚开始给网页写footer的时候,我们会碰到一个让人烦躁的问题:当页面内容太少时,footer显示在了页面中间,这是我们不希望出现的,我们希望它能够永远呆在底部,不管网页的内容是多还是少.下面的代码 ...
- 使用phpstorm+wamp实现php代码实时调试审计
转载自:https://www.bugbank.cn/q/article/5853afaffc0bf4f010ee6ac3.html php调试有N多好用的工具,最近研究到phpstorm配合wamp ...
- 【ARTS】01_02_左耳听风-20181119~1125
Algorithm 做一个 leetcode 的算法题 Unique Email Addresses https://leetcode.com/problems/unique-email-addres ...
- make distclean
清空bin目录make dirclean 清空所有相关的东西,包括下载的软件包,配置文件,feeds内容等make distclean 这个命令会删除feeds目录及其下面的所有的文件,直接结果就是运 ...
- ipsec-tools安装教程
ipsec-tools最新版本为0.8.2,此处以0.7.3版本为例说明安装和使用过程.可参考ipsec-howto. 安装步骤 ipsec-tools依赖于linux2.6版本内核,在安装ipsec ...
- MongoDB:数据导入CSV文件之错误记录
测试主机1:Windows 10,MongoDB 3.6.3,WPS 10.1,Notepad++ 7.5.3, 测试主机2:Ubuntu 16.04,MongoDB 4, 今天测试了将数据从文件—— ...
- win7(x64)安装scrapy框架
Scrapy(官网http://scrapy.org/)是Python开发网络爬虫,一个极好的开源工具.本次安装Scrapy确实不易啊.居然花了2天多时间,需要的支持包比较多,这些支持包相互之间的依赖 ...
- java 通过异常处理错误
java的基本理念是"结构不佳的代码不能够运行" 一.概念 发现错误的理想时机是编译阶段,然而,编译期间并不能找出所有的错误,余下的问题必须在运行时期解决. 二.基本异常 异常情形 ...
- EFCore CodeFirst 适配数据库
EF6中可以直接根据代码模型生成数据库Database.SetInitializer即可 在EFCore中如何实现呢? 这项功能放在了DatabaseFacade对象中,传入数据库上下文对象实例化到一 ...