POJ - 2991

思路:

  向量旋转;

代码:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; #define maxn 400005 const double pi=acos(-1.0); struct TreeNodeType {
int l,r,R,mid,flag; double x,y; void mem()
{
x=,R=;
scanf("%lf",&y);
} void rotate(int R__)
{
double tmp_x=x,tmp_y=y,R_=R__/180.0*pi;
x=tmp_x*cos(R_)-tmp_y*sin(R_);
y=tmp_y*cos(R_)+tmp_x*sin(R_);
}
};
struct TreeNodeType tree[maxn<<]; int n,m; void build(int now,int l,int r)
{
tree[now].l=l,tree[now].r=r,tree[now].flag=;
if(tree[now].l==tree[now].r) { tree[now].mem();return; }
tree[now].mid=l+r>>;build(now<<,l,tree[now].mid),build(now<<|,tree[now].mid+,r);
tree[now].x=tree[now<<].x+tree[now<<|].x,tree[now].y=tree[now<<].y+tree[now<<|].y;
} int query(int now,int to,int x)
{
if(tree[now].l==tree[now].r){int pos=x-tree[now].R;tree[now].R=x;return pos;}
if(to<=tree[now].mid) return query(now<<,to,x);else return query(now<<|,to,x);
} void updata(int now)
{
tree[now<<].flag+=tree[now].flag,tree[now<<|].flag+=tree[now].flag;
tree[now<<].rotate(tree[now].flag),tree[now<<|].rotate(tree[now].flag);
tree[now].flag=;
} void change(int now,int l,int r,int x)
{
if(tree[now].l==l&&tree[now].r==r) {tree[now].flag+=x,tree[now].rotate(x);return;}
if(tree[now].flag) updata(now);if(l>tree[now].mid) change(now<<|,l,r,x);
else if(r<=tree[now].mid) change(now<<,l,r,x);
else change(now<<,l,tree[now].mid,x),change(now<<|,tree[now].mid+,r,x);
tree[now].x=tree[now<<].x+tree[now<<|].x,tree[now].y=tree[now<<].y+tree[now<<|].y;
} int main()
{
int T=;
while(scanf("%d%d",&n,&m)!=EOF)
{
if(T++) printf("\n");
build(,,n);int to,x;
for(;m--;)
{
scanf("%d%d",&to,&x);
change(,to+,n,query(,to+,x));
printf("%.2lf %.2lf\n",tree[].x,tree[].y);
}
}
return ;
}

AC日记——Crane poj 2991的更多相关文章

  1. AC日记——Tree poj 3237

    Tree Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 9233   Accepted: 2431 Description ...

  2. AC日记——Dividing poj 1014

    Dividing Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 69575   Accepted: 18138 Descri ...

  3. AC日记——pigs poj 1149

    POJ - 1149 思路: 最大流: 代码: #include <cstdio> #include <cstring> #include <iostream> # ...

  4. Crane (POJ 2991)

    //线段树 延迟标签 // #include <bits/stdc++.h> using namespace std; const int maxn=1e4+5; double x[max ...

  5. AC日记——Dining poj 3281

    [POJ-3281] 思路: 把牛拆点: s向食物连边,流量1: 饮料向t连边,流量1: 食物向牛1连边,流量1: 牛2向饮料连边,流量1: 最大流: 来,上代码: #include <cstd ...

  6. AC日记——Two poj 1849

    Two 思路: 树形DP求直径: 答案是边权总和*2-直径: dp[i][1]::以i为根的子树中最长的路径: dp[i][0]::以i为根的子树中次长的路径: 来,上代码: #include < ...

  7. AC日记——Oulipo poj 3461

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37958   Accepted: 15282 Description The ...

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

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

  9. AC日记——codevs1688求逆序对

    AC日记--codevs1688求逆序对 锵炬 掭约芴巷 枷锤霍蚣 蟠道初盛 到被他尽情地踩在脚下蹂躏心中就无比的兴奋他是怎么都 ㄥ|囿楣 定要将他剁成肉泥.挫骨扬灰跟随着戴爷这么多年刁梅生 圃鳋 ...

随机推荐

  1. 搭建springmvc项目没扫描到mapper和service

    严重: Servlet.service() for servlet [spring] in context with path [/springmvc-demo] threw exceptionorg ...

  2. (转)Loadrunner监控Linux的17个指标

    1.Average load:Average number of processes simultaneously in Ready state during the last minute.   上 ...

  3. Laravel 5 如何实现网站在维护模式下允许指定 IP 用户访问(白名单)

    为了测试需要,有时候需要在网站处于维护模式下允许特定IP访问网站,在 Laravel 中,这可以通过为维护模式编写自定义中间件来实现. 默认情况下,Laravel 使用 CheckForMainten ...

  4. 对Web作用域变量进行迭代

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ pa ...

  5. oracle 导入导出语句

    imp USERID/PSD@SID file='D:\1.dmp' full=y statistics=none exp USERID/PSD@SID file='D:\1.dmp' tables= ...

  6. AngularJs学习——实现数据绑定的三种方式

    三种方式: 方式一:<h5>{{msg}}</h5>  此方式在页面刷新的时候会闪现{{}} 方式二:<h5 ng-bind="msg">< ...

  7. Jquery Ajax异步上传

    <script> $(function(){ $('#filephoto').change(function(imgFile){ console.log(imgFile) var file ...

  8. 【uva11855-求长度为1到n的相同子串出现的次数】sam

    题意:求长度为1到n的相同子串出现的次数,输到小于2为止. 题解: 用sam做. 建机,算right集合,然后用r[i]更新长度为step[i]的子串出现次数,然后ans[i]=maxx(ans[i] ...

  9. Bzoj4197 寿司晚宴

    Description 为了庆祝 NOI 的成功开幕,主办方为大家准备了一场寿司晚宴.小 G 和小 W 作为参加 NOI 的选手,也被邀请参加了寿司晚宴. 在晚宴上,主办方为大家提供了 n−1 种不同 ...

  10. CF502C The Phone Number

    C. The Phone Number time limit per test 1 second memory limit per test 256 megabytes     Mrs. Smith ...