记录编号 |
202358 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[SYOI 2015] Asm.Def的命令 |
最终得分 |
100 |
用户昵称 |
dydxh |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
8.320 s |
提交时间 |
2015-10-31 23:17:55 |
内存使用 |
106.91 MiB |
显示代码纯文本
/*
Problem:game;
Language:c++;
by dydxh;
2015.10.18;
*/
#include<iostream>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<utility>
#include<ctime>
#include<cstdlib>
#include<string>
#define ull unsigned long long
#define uint unsigned int
#define ll long long
using namespace std;
const int maxn=100005;
const int oo=2000000000;
const double Pi=acos(-1.0);
int n,Q,Fence_L,Fence_R;
inline int read(){
int x=0;bool flag=0;char ch=getchar();
while(ch>'9' || ch<'0') {if(ch=='-') flag=1;ch=getchar();}
while(ch>='0' && ch<='9') {x=x*10+ch-'0';ch=getchar();}
return flag?-x:x;
}
struct Matrix{
int r,c;
double o[4][4];
inline void Clear(int _r,int _c){
r=_r,c=_c;
for(int i=0;i<=3;i++)
for(int j=0;j<=3;j++)
o[i][j]=0;
}
inline void _New(int _r,int _c,int i){
Clear(_r,_c);
o[1][1]=0,o[2][1]=i,o[3][1]=1;
}
inline void Unit(int T){
Clear(T,T);
for(int i=1;i<=T;i++) o[i][i]=1.0;
}
}Flower;
inline Matrix operator * (const Matrix &a,const Matrix &b){
Matrix c;c.Clear(a.r,b.c);
for(int i=1;i<=c.r;i++)
for(int j=1;j<=c.c;j++)
for(int k=1;k<=a.c;k++)
c.o[i][j]+=a.o[i][k]*b.o[k][j];
return c;
}
struct Seg_Ment{
Matrix Status,Delta;
}tree[maxn<<2];
void Build_Tree(int Lef,int Rig,int x){
tree[x].Delta.Unit(3);
if(Lef==Rig){
tree[x].Status._New(3,1,Lef);
return ;
}
int Mid=(Lef+Rig)>>1;
Build_Tree(Lef,Mid,x<<1);
Build_Tree(Mid+1,Rig,x<<1|1);
}
void Mover(){
Flower.o[1][1]=1,Flower.o[1][2]=0,Flower.o[1][3]=read();
Flower.o[2][1]=0,Flower.o[2][2]=1,Flower.o[2][3]=read();
Flower.o[3][1]=0,Flower.o[3][2]=0,Flower.o[3][3]=1;
}
void Rotater(){
double Degree=1.0*read()/180*Pi;
double _Cos=cos(Degree),_Sin=sin(Degree);
Flower.o[1][1]=_Cos,Flower.o[1][2]=-_Sin,Flower.o[1][3]=0;
Flower.o[2][1]=_Sin,Flower.o[2][2]=_Cos,Flower.o[2][3]=0;
Flower.o[3][1]=0,Flower.o[3][2]=0,Flower.o[3][3]=1;
}
bool Judge(const Matrix &c){
for(int i=1;i<=3;i++)
for(int j=1;j<=3;j++){
if(i==j) continue;
if(c.o[i][j]!=0) return false;
}
return true;
}
void Push_Down(int x){
if(Judge(tree[x].Delta)) return ;
tree[x<<1].Delta=tree[x].Delta*tree[x<<1].Delta;
tree[x<<1|1].Delta=tree[x].Delta*tree[x<<1|1].Delta;
tree[x<<1].Status=tree[x].Delta*tree[x<<1].Status;
tree[x<<1|1].Status=tree[x].Delta*tree[x<<1|1].Status;
tree[x].Delta.Unit(3);
}
void Modify(int Lef,int Rig,int x){
if(Fence_R<Lef || Rig<Fence_L) return ;
if(Fence_L<=Lef && Rig<=Fence_R){
tree[x].Status=Flower*tree[x].Status;
tree[x].Delta=Flower*tree[x].Delta;
return ;
}
Push_Down(x);
int Mid=(Lef+Rig)>>1;
Modify(Lef,Mid,x<<1);
Modify(Mid+1,Rig,x<<1|1);
}
inline Seg_Ment Query(int Lef,int Rig,int x){
if(Lef==Rig && Lef==Fence_L) return tree[x];
Push_Down(x);
int Mid=(Lef+Rig)>>1;
if(Fence_L<=Mid) return Query(Lef,Mid,x<<1);
return Query(Mid+1,Rig,x<<1|1);
}
int main(){
freopen("asm_command.in","r",stdin);
freopen("asm_command.out","w",stdout);
n=read(),Q=read();
Build_Tree(1,n,1);
Flower.Clear(3,3);
while(Q--){
int Ope=read();
if(!Ope){
Fence_L=Fence_R=read();
Matrix opt=Query(1,n,1).Status;
printf("%.1lf %.1lf\n",opt.o[1][1],opt.o[2][1]);
}
else{
Fence_L=read(),Fence_R=read();
if(Ope&1) Mover();
else Rotater();
Modify(1,n,1);
}
}
return 0;
}