//线段树 延迟标签
//
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e4+5;
double x[maxn*4];
double y[maxn*4];
int degreen[maxn];
int d[maxn*4];//延迟标签
void rotate(int i,int num)
{
double ang=(1.0*num)/180*acos(-1);
double newx=x[i]*cos(ang)-y[i]*sin(ang);//向量逆时针转动后的x坐标;
double newy=x[i]*sin(ang)+y[i]*cos(ang);
x[i]=newx;
y[i]=newy;
}
void pushdown(int i)
{
d[i<<1]+=d[i];
d[i<<1|1]+=d[i];
rotate(i<<1,d[i]);
rotate(i<<1|1,d[i]);
d[i]=0;
}
void pushup(int i)
{
x[i]=x[i<<1]+x[i<<1|1];
y[i]=y[i<<1]+y[i<<1|1];
}
void build(int l,int r,int root)
{
d[root]=0;
if(l==r)
{
x[root]=0;
scanf("%lf",&y[root]);
return;
}
int mid=(l+r)>>1;
build(l,mid,root<<1);
build(mid+1,r,root<<1|1);
pushup(root);
}
void update(int index,int l,int r,int root,int ang)
{
if(l>=index)
{
rotate(root,ang);
d[root]+=ang;
return;
}
int mid=l+r>>1;
pushdown(root);
if(index<=mid)
update(index,l,mid,root<<1,ang);
update(index,mid+1,r,root<<1|1,ang);
pushup(root);
}
int main()
{
int n,c;
scanf("%d%d",&n,&c);
build(1,n,1);
for(int i = 1;i <= n;++i)
degreen[i]=180;
for(int i = 1;i <= c;++i)
{
int a,b;
scanf("%d%d",&a,&b);
update(a+1,1,n,1,b-degreen[a]);
degreen[a]=b;
printf("%.2lf %.2lf\n",x[1],y[1]);
}
return 0;
}

Crane (POJ 2991)的更多相关文章

  1. AC日记——Crane poj 2991

    POJ - 2991 思路: 向量旋转: 代码: #include <cmath> #include <cstdio> #include <cstring> #in ...

  2. POJ 2991 Crane(线段树+计算几何)

    POJ 2991 Crane 题目链接 题意:给定一个垂直的挖掘机臂.有n段,如今每次操作能够旋转一个位置,把[s, s + 1]专程a度,每次旋转后要输出第n个位置的坐标 思路:线段树.把每一段当成 ...

  3. (中等) POJ 2991 Crane , 几何+线段树。

    Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of variou ...

  4. POJ 2991 Crane(线段树)

    Crane Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7687   Accepted: 2075   Special J ...

  5. POJ 2991 Crane (线段树)

    题目链接 Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of v ...

  6. POJ - 2991 Crane (段树+计算几何)

    Description ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of variou ...

  7. POJ 2991–Crane【线段树+几何】

    题意: 把手臂都各自看成一个向量,则机械手的位置正好是手臂向量之和.旋转某个关节,其实就是把关节到机械手之间的手臂向量统统旋转. 由于手臂很多,要每个向量做相同的旋转操作很费时间.这时就可以想到用线段 ...

  8. [poj 2991]Crane[线段树表示向量之和,而非数量]

    题意: 起重机的机械臂, 由n段组成, 对某一些连接点进行旋转, 询问每次操作后的末端坐标. 思路: 由于旋转会影响到该点之后所有线段的角度, 因此容易想到用线段树记录角度, 成段更新. (但是不是每 ...

  9. POJ 2991 Crane

    线段树+计算几何,区间更新,区间求和,向量旋转. /* *********************************************** Author :Zhou Zhentao Ema ...

随机推荐

  1. Access denied when I try to install profiler

    I had the same issue and used the diagtool to find more information. The traces showed this error me ...

  2. ipython notebook 安装

    pip install IPython pip install urllib3 pip install jupyter pip install numpy pip install matplotlib ...

  3. 利用CNN神经网络实现手写数字mnist分类

    题目: 1)In the first step, apply the Convolution Neural Network method to perform the training on one ...

  4. Linux高级指令

    一.hostname指令 作用:操作服务器的主机名(读取,设置) #hostname    作用:表示输出完整的主机名 #hostname -f    作用:表示输出当前主机名中的FQDN(权限定域名 ...

  5. 2018-2019-2 20165205 《网络对抗》 Exp5 MSF基础

    2018-2019-2 20165205 <网络对抗> Exp5 MSF基础 实验内容 本实践目标是掌握metasploit的基本应用方式,重点常用的三种攻击方式的思路.具体需要完成: 1 ...

  6. 在eclipse下,用Maven创建Spring MVC工程

    参考链接:https://www.cnblogs.com/yangyxd/p/5955630.html 1.打开Eclipse,Ctrl + N  创建Maven

  7. Xeon Phi 《协处理器高性能编程指南》随书代码整理 part 4

    ▶ 第五章,几个优化 ● 代码 #include <stdio.h> #include <stdlib.h> #include <math.h> #define S ...

  8. 使用shell命令给文件中每一行的前面、后面添加字符

    shell command shell给一个文件中的每一行开头插入字符的方法:awk '{print "xxx"$0}' fileName shell给一个文件中的每一行结尾插入字 ...

  9. thinkPHP nginx无论怎样访问都会访问index方法解决

    修改项目配置文件 application/config.php中的 pathinfo_fetch的末尾增加 REQUEST_URI 详情参考:https://www.colabug.com/35205 ...

  10. JDBC数据库连接参数备忘

    database driver url remark MySql com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/xxx mysql-connect ...