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. Spring和SpringMVC配置中父子WebApplicationContext的关系

    一.前言 有这么一个故事:一辆装满石头的板车,一根绳子系着,起初绳子没有拉直,拉绳的人以为很轻,等真的绷直了才发现自己的力气根本不够~人往往喜欢得过且过,但是有些东西真的是绕不过的,所以现在必须努力的 ...

  2. [Leetcode] 20. Valid Parentheses(Stack)

    括号匹配问题,使用栈的特点,匹配则出栈,否则入栈,最后栈为空则全部匹配.代码如下: class Solution { public: bool isValid(string s) { stack< ...

  3. well-known file is not secure

    执行jstack pid时,提示well-known file is not secure. 原因是pid的启动用户不是当前用户,需要切换到启动用户下执行jstack即可. 可以通过如下命令来处理: ...

  4. javascript中window.location.search方法简介

    window.location.search方法是截取当前url中"?"后面的字符串,示例如下: 例如:http://www.firefoxchina.cn/?ntab截取后的字符 ...

  5. 2017 Multi-University Training Contest - Team 3 RXD and dividing(树)

    题解: 其实贪心地算就可以了 一个最优的分配就是每条边权贡献的值为min(k, sz[x]),sz[x]是指子树的大小 然后最后加起来就是答案. #include <iostream> # ...

  6. poj3347 Kadj Squares (计算几何)

    D - Kadj Squares Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Su ...

  7. [Leetcode] Add two numbers 两数之和

    You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...

  8. [BZOJ3829][Poi2014]FarmCraft 贪心

    这个题应该是很容易想到贪心的,只要可是怎么贪才是科学的呢?我们分析一下题干,对于每个边只能一进一出因此,对于树上的一棵子树,我们只要一进子树就必须遍历完,因此我们只能进行一遍 dfs() 然后我们发现 ...

  9. [poj 2796]单调栈

    题目链接:http://poj.org/problem?id=2796 单调栈可以O(n)得到以每个位置为最小值,向左右最多扩展到哪里. #include<cstdio> #include ...

  10. js中连写两个?:三元运算符语法解释

    在angular 源码中有连写两个三元运算符的代码: var hash = isString(hash) ? hash : isNumber(hash) ? hash.toString() :$loc ...