Joy of Flight

题目连接:

http://codeforces.com/gym/100531/attachments

Description

Jacob likes to play with his radio-controlled aircraft. The weather today is pretty windy and Jacob has

to plan flight carefully. He has a weather forecast — the speed and direction of the wind for every second

of the planned flight.

The plane may have airspeed up to vmax units per second in any direction. The wind blows away plane

in the following way: if airspeed speed of the plane is (vx, vy) and the wind speed is (wx, wy), the plane

moves by (vx + wx, vw + wy) each second.

Jacob has a fuel for exactly k seconds, and he wants to learn, whether the plane is able to fly from start

to finish in this time. If it is possible he needs to know the flight plan: the position of the plane after

every second of flight.

Input

The first line of the input file contains four integers Sx, Sy, Fx, Fy — coordinates of start and finish

(−10 000 ≤ Sx, Sy, Fx, Fy ≤ 10 000).

The second line contains three integers n, k and vmax — the number of wind condition changes, duration

of Jacob’s flight in seconds and maximum aircraft speed (1 ≤ n, k, vmax ≤ 10 000).

The following n lines contain the wind conditions description. The i-th of these lines contains integers

ti

Output

The first line must contain “Yes” if Jacob’s plane is able to fly from start to finish in k seconds, and “No”

otherwise.

If it can to do that, the following k lines must contain the flight plan. The i-th of these lines must contain

two floating point numbers x and y — the coordinates of the position (Pi) of the plane after i-th second

of the flight.

The plan is correct if for every 1 ≤ i ≤ k it is possible to fly in one second from Pi−1 to some point

Qi

, such that distance between Qi and Pi doesn’t exceed 10−5

, where P0 = S. Moreover the distance

between Pk and F should not exceed 10−5 as well.

Sample Input

1 1 7 4

2 3 10

0 1 2

2 2 0

Sample Output

Yes

3 2.5

5 2.5

7 4

Hint

题意

给你一个起点和终点,然后会有风,问你能否在k秒内到达终点

如果可以的话,就输出每一秒之后,你在哪儿

题解:

和CF的某道题一样的,把坐标系变换一下,把风直接的按在终点倒着跑

然后直接看一下时间是否小于等于k就好了

如果小于的话,就直接跑平均速度就好了

代码

#include<bits/stdc++.h>
using namespace std; double sx,sy,fx,fy;
int n,k,t[20005];
double v,wx[20005],wy[20005];
double vx,vy;
int tot = 0;
double winx=0,winy=0;
int check(int mid)
{
tot = 0,winx = winy = 0;
double ex = fx,ey = fy;
for(int i=0;i<mid;i++)
{
if(tot<n&&t[tot]==i)
winx=wx[tot],winy=wy[tot],tot++;
ex-=winx,ey-=winy;
}
double dis = sqrt((ex-sx)*(ex-sx)+(ey-sy)*(ey-sy));
if(dis/v>mid)return 0;
return 1;
}
int main()
{
freopen("joy.in","r",stdin);
freopen("joy.out","w",stdout);
cin>>sx>>sy>>fx>>fy;
cin>>n>>k>>v;
for(int i=0;i<n;i++)
cin>>t[i]>>wx[i]>>wy[i];
int L = 0;
for(;L<=k+5;L++)
if(check(L))
break;
if(L>k)return puts("No");
double ex = fx,ey = fy;
tot = winx = winy = 0;
for(int i=0;i<L;i++)
{
if(tot<n&&t[tot]==i)
winx=wx[tot],winy=wy[tot],tot++;
fx-=winx,fy-=winy;
}
double l = fx - sx;
double h = fy - sy;
double dis = sqrt(l*l+h*h);
double vx = v * l / dis;
double vy = v * h / dis;
tot = winx = winy = 0;
puts("Yes");
if(L==0)L++;
for(int i=0;i<L-1;i++)
{
if(tot<n&&t[tot]==i)
winx=wx[tot],winy=wy[tot],tot++;
sx += vx + winx;
sy += vy + winy;
printf("%.6f %.6f\n",sx,sy);
}
for(int i=L;i<=k;i++)
printf("%.6f %.6f\n",ex,ey);
}

Codeforces Gym 100531J Joy of Flight 变换坐标系的更多相关文章

  1. Gym 100531J Joy of Flight (几何)

    题意:你从开始坐标到末尾坐标,要经过 k 秒,然后给你每秒的风向,和飞机的最大速度,问能不能从开始到末尾. 析:首先这个风向是不确定的,所以我们先排除风向的影响,然后算出,静风是的最小速度,如果这都大 ...

  2. Codeforces Gym 101252D&&floyd判圈算法学习笔记

    一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...

  3. Codeforces Gym 101190M Mole Tunnels - 费用流

    题目传送门 传送门 题目大意 $m$只鼹鼠有$n$个巢穴,$n - 1$条长度为$1$的通道将它们连通且第$i(i > 1)$个巢穴与第$\left\lfloor \frac{i}{2}\rig ...

  4. Codeforces Gym 101623A - 动态规划

    题目传送门 传送门 题目大意 给定一个长度为$n$的序列,要求划分成最少的段数,然后将这些段排序使得新序列单调不减. 考虑将相邻的相等的数缩成一个数. 假设没有分成了$n$段,考虑最少能够减少多少划分 ...

  5. 【Codeforces Gym 100725K】Key Insertion

    Codeforces Gym 100725K 题意:给定一个初始全0的序列,然后给\(n\)个查询,每一次调用\(Insert(L_i,i)\),其中\(Insert(L,K)\)表示在第L位插入K, ...

  6. Codeforces gym 101343 J.Husam and the Broken Present 2【状压dp】

     2017 JUST Programming Contest 2.0 题目链接:Codeforces gym 101343 J.Husam and the Broken Present 2 J. Hu ...

  7. codeforces gym 100553I

    codeforces gym 100553I solution 令a[i]表示位置i的船的编号 研究可以发现,应是从中间开始,往两边跳.... 于是就是一个点往两边的最长下降子序列之和减一 魔改树状数 ...

  8. CodeForces Gym 100213F Counterfeit Money

    CodeForces Gym题目页面传送门 有\(1\)个\(n1\times m1\)的字符矩阵\(a\)和\(1\)个\(n2\times m2\)的字符矩阵\(b\),求\(a,b\)的最大公共 ...

  9. Codeforces GYM 100876 J - Buying roads 题解

    Codeforces GYM 100876 J - Buying roads 题解 才不是因为有了图床来测试一下呢,哼( 题意 给你\(N\)个点,\(M\)条带权边的无向图,选出\(K\)条边,使得 ...

随机推荐

  1. 一些JS周边工具

    Visual Studio JS 辅助插件 JScript Editor Extensions 功能: 1.     代码块折叠 2.     方法参数智能提示 3.     代码块Outlining ...

  2. R command

    setwd("D:/Research/code/rcode")    #notice the "/" list.files(getwd()) heisenber ...

  3. MVC&&MVP

    Classic MVC Classic MVC 大概上世纪七十年代,Xerox PARC的Trygve提出了MVC的概念. 并应用在Smalltalk系统中,为了和其它类型的MVC加以区分,历史上习惯 ...

  4. (转载)OC学习篇之---Foundation框架中的NSObject对象

    前一篇文章讲到了OC中的代理模式,而且前几篇文章就介绍了OC中的类相关知识,从这篇文章开始我们开始介绍Foundation框架. OC中的Foundation框架是系统提供了,他就相当于是系统的一套a ...

  5. IOS平台设计规范

    一.UI的控件概述: 1.框架UI的元素分为4类: A:栏:状态栏目和导航栏的结合体; B:内容视图:应用显示的内容信息,包括相关的交互行为,例如滚屏.插入.删除等操作进行排序; C:控制元素:产品行 ...

  6. Linux系统下查看已经登录用户并踢出的方法

    LINUX是个多用户系统,一旦连接到网络中,它可以同时为多个登录用户提供服务. 查看用户的操作 查看当前用户: [ROOT@LOCALHOST ROOT] # W                    ...

  7. 解决“运行arm-linux-gcc命令,提示No such file or directory”的问题

    今天在ubuntu14.04上安装arm的交叉编译器arm-linux-gcc,环境变量配置好以后,运行arm-linux-gcc命令,总提示No such file or directory.然后去 ...

  8. 实体框架 (EF) 入门 => 五、连接和模型

    public class BloggingContext : DbContext  {  public BloggingContext()          : base("name=Blo ...

  9. iPhone 6/6 Plus 出现后,如何改进工作流以实现一份设计稿支持多个尺寸?

    iPhone 6/6 Plus 出现后,如何改进工作流以实现一份设计稿支持多个尺寸? 2014-12-05 09:33 编辑: suiling 分类:iOS开发 来源:知乎(pigtwo)  2 22 ...

  10. 关于 三星 I9100 (水货)

    前天陪好友去买水货9100,总结了一点经验,觉得挺有用的,今天整理一下写出来...有 需要的可以看看..原创整理.. 一,当然是检查外观(检查USB接口有没有磨损,检查摄像头是否有灰尘,检查屏幕是不是 ...