-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2991.cpp
More file actions
98 lines (93 loc) · 1.86 KB
/
2991.cpp
File metadata and controls
98 lines (93 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define PI 3.1415926535
using namespace std;
int a[10008];
struct Node
{
double x,y;
Node operator+(Node ano) const
{
Node res={x+ano.x,y+ano.y};
return res;
}
Node rotate(double a)
{
Node res={cos(a)*x+sin(a)*y,-sin(a)*x+cos(a)*y};
return res;
//return (Node){cos(a)*x-sin(a)*y,sin(a)*x+cos(a)*y};
}
} vec[40008];
double add[40008],prv[10008];
void init(int o,int L,int r)
{
add[o]=0;
if(L+1==r)
{
vec[o].x=0;
vec[o].y=a[L];
}
else
{
int M=L+(r-L)/2;
init(o*2,L,M);
init(o*2+1,M,r);
vec[o]=vec[o*2]+vec[o*2+1];
}
}
void pushdown(int o,int L,int r)
{
if(L+1<r)
{
add[o*2]+=add[o];//+=
vec[o*2]=vec[o*2].rotate(add[o]);
add[o*2+1]+=add[o];
vec[o*2+1]=vec[o*2+1].rotate(add[o]);
}
add[o]=0;//attention!!!
}
int up_L,up_r;
double delta;
void update(int o,int L,int r)
{
if(r<=up_L || L>=up_r)
return;
if(up_L<=L && r<=up_r)
{
add[o]+=delta;
vec[o]=vec[o].rotate(delta);
return;
}
pushdown(o,L,r);
int M=L+(r-L)/2;
update(o*2,L,M);
update(o*2+1,M,r);
vec[o]=vec[o*2]+vec[o*2+1];
}
int main()
{
int n,c;
while(scanf("%d%d",&n,&c)!=EOF)
{
for(int i=1;i<=n;++i)
scanf("%d",&a[i]);
fill(prv+1,prv+n,PI);
init(1,1,n+1);
for(int i=1;i<=c;++i)
{
int which,tmp;
scanf("%d%d",&which,&tmp);
double angle=tmp/180.0*PI;
delta=prv[which]-angle;
up_L=which+1;
up_r=n+1;
update(1,1,n+1);
prv[which]=angle;
printf("%.2lf %.2lf\n",vec[1].x,vec[1].y);
}
printf("\n");
}
return 0;
}