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. vs2017切换设计、拆分假死的解决

    今天安装了vs2017版把vs2015卸载了,原因就是vs2015运行webform后ajaxpro总是会出现time out现象.太难受了,所以决定体验一下新版本. 安装了vs2017后ajaxpr ...

  2. Linux在线用户通信

    1,/etc/motd文件 该文件即 message of today(布告栏信息),每次用户登录时,/etc/motd文件的内容会显示在用户的终端.系统管理员可以在文件中编辑系统活动消息 即像公告栏 ...

  3. doget,doPost在底层走的是service

    doget,doPost在底层走的是service 因为在源码上 先执行service方法 然后再调用doget,doPost方法

  4. android中常见的命名及其特点详解

    Paseal命名法 Paseal命名法特点:String MyName-DelphiInt MyAge每个单词首字母大写 Camel命名法 Camel(驼峰的意思)命名法特点:String myNam ...

  5. BZOJ4551 Tjoi2016&Heoi2016树(离线+并查集)

    似乎是弱化的qtree3.树剖什么的非常无脑.考虑离线.并查集维护每个点的最近打标记祖先,倒序处理,删除标记时将其与父亲合并即可. #include<iostream> #include& ...

  6. [洛谷P1131][ZJOI2007]时态同步

    题目大意:给你一棵树,每条边有边权,要求增加一些边的边权,使得根节点到每个叶子节点的距离相等,求出最少共增加多少边权. 题解:树形$DP$,对于每个点,如果它到它的子树中的叶子节点距离不同,一定要在这 ...

  7. C++——拷贝构造函数说明

    一. 什么是拷贝构造函数 首先对于普通类型的对象来说,它们之间的复制是很简单的,例如: [c-sharp] view plaincopy 1 int a = 100; 2 int b = a; 而类对 ...

  8. BZOJ_day4&&DSFZ_day1

    昨天坐火车才水了三道题... 25题 100810221041105110591087108811791191119212571303143218541876195119682140224224382 ...

  9. [SCOI2007] 蜥蜴 (最大流)

    [SCOI2007] 蜥蜴 题目背景 07四川省选 题目描述 在一个r行c列的网格地图中有一些高度不同的石柱,一些石柱上站着一些蜥蜴,你的任务是让尽量多的蜥蜴逃到边界外. 每行每列中相邻石柱的距离为1 ...

  10. 怎么让Intellj Idea 把数据库的表映射成hibernate的domain对象

    步骤如下: 第一步:连接数据源: 点击:idea右边的database.如下图所示: 或者你依次点击:view-->Tool windows--->database 然后你将看在如下点击下 ...