//线段树 延迟标签
//
#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. DP基础练习(4.21)

    数塔 Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少? ...

  2. pandas学习笔记(一)

    Pandas是一款开放源码的BSD许可的Python库,为Python编程语言提供了高性能,易于使用的数据结构和数据分析工具.Pandas用于广泛的领域,包括金融,经济,统计,分析等学术和商业领域.在 ...

  3. FTP学习笔记

    FTP有两个连接方式 1.控制连接 2.数据连接 控制链接 标准端口为21  用于数据传输中的控制 数据连接 标准端口20  用于数据传输中的上传 下载数据 数据传输的连接方式,主动连接 被动连接. ...

  4. MySQL计算年龄

    SELECT TIMESTAMPDIFF(YEAR, birthday, now()) FROM person2;

  5. 关于matlab2018a版本错误使用 svmclassify 分类器

    当我们照常使用分类器函数svmclassify时,2018版的matlab会报出以下错误: 解决办法: 1,下载libsvm(一般下载最新版本就ok了)包,并将其添加至matlab的toolbox文件 ...

  6. TreeMap中文排序,TreeMap倒序输出排列

    1.TreeMap集合倒序排列 import java.util.Comparator; /** * 比较算法的类,比较器 * @author Administrator * */ public cl ...

  7. sql获取时间段内的所有日期

    ,'2015-01-01 00:00:00') h INTO vinson_h DELETE vinson_h DECLARE @h int SELECT @h=DATEDIFF(HOUR,'2015 ...

  8. redis--解析字符串

    # coding=utf-8import codecs if __name__ == '__main__': cmdlist = ("Decode") while True: cm ...

  9. C#创建windows服务并发布

    创建window 服务 新建一个window 服务项目MyService,如下图 切换到代码视图修改. using System; using System.Collections.Generic; ...

  10. 72.纯 CSS 创作气泡填色的按钮特效

    原文地址:https://segmentfault.com/a/1190000015560736 感想:过渡效果+xyz中一轴. HTML code: <nav> <ul> & ...