比赛 |
Asm.Def战记之圣地亚哥“杯2015 |
评测结果 |
AAAAAAEWEE |
题目名称 |
Asm.Def的命令 |
最终得分 |
60 |
用户昵称 |
Fmuckss |
运行时间 |
0.706 s |
代码语言 |
C++ |
内存使用 |
12.52 MiB |
提交时间 |
2015-10-31 11:49:25 |
显示代码纯文本
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<vector>
#include<map>
#include<queue>
#define maxn 100000
int n,m;
struct poi{
int x,y;
};
struct node{
int l,r,i;
int tx,ty;
int sumx,sumy;
bool con[2];
}ns[maxn*4];
void build_tree(int l,int r,int i){
ns[i].l=l;ns[i].r=r;ns[i].i=i;
if(r==l) return;
int mid=(l+r)/2;
build_tree(l,mid,i*2);
build_tree(mid+1,r,i*2+1);
}
void updata(int l,int r,int i,int ux,int uy){
if(ns[i].con[1]){
ns[i*2].con[1]=true;
ns[i*2+1].con[1]=true;
ns[i*2].sumx+=ns[i].sumx;
ns[i*2].sumy+=ns[i].sumy;
ns[i*2+1].sumx+=ns[i].sumx;
ns[i*2+1].sumy+=ns[i].sumy;
ns[i].con[1]=false;
ns[i].tx+=ns[i].sumx;
ns[i].ty+=ns[i].sumy;
ns[i].sumx=ns[i].sumy=0;
}
if(l==ns[i].l&&r==ns[i].r){
ns[i].sumx+=ux;
ns[i].sumy+=uy;
if(l!=r)ns[i].con[1]=true;
return;
}
if(r<=ns[i*2].r){updata(l,r,i*2,ux,uy);}
else if(l>=ns[i*2+1].l){updata(l,r,i*2+1,ux,uy);}
else if(l<=ns[i*2].r&&r>=ns[i*2+1].l){updata(l,ns[i*2].r,i*2,ux,uy);updata(ns[i*2+1].l,r,i*2+1,ux,uy);}
}
poi search(int l,int r,int i){
if(ns[i].con[1]){
ns[i*2].con[1]=true;
ns[i*2+1].con[1]=true;
ns[i*2].sumx+=ns[i].sumx;
ns[i*2].sumy+=ns[i].sumy;
ns[i*2+1].sumx+=ns[i].sumx;
ns[i*2+1].sumy+=ns[i].sumy;
ns[i].con[1]=false;
ns[i].tx+=ns[i].sumx;
ns[i].ty+=ns[i].sumy;
ns[i].sumx=ns[i].sumy=0;
}
if(l==ns[i].l&&r==ns[i].r){
poi tmp;
tmp.x=ns[i].tx+ns[i].sumx;
tmp.y=ns[i].ty+ns[i].sumy;
return tmp;
}
int mid=(l+r)/2;
if(r<=ns[i*2].r){return search(l,r,i*2);}
else if(l>=ns[i*2+1].l){return search(l,r,i*2+1);}
}
void han1(){
int be,en,bx,by;
scanf("%d %d %d %d",&be,&en,&bx,&by);
updata(be,en,1,bx,by);
}
void han0(){
int tar;
scanf("%d",&tar);
poi tmp=search(tar,tar,1);
// printf("tar:%d %d %d\n",tar,tmp.x,tmp.y);
printf("%.1lf %.1lf\n",(double)(tmp.x),(double)(tar+tmp.y));
}
void han2(){
int be,en,deg;
scanf("%d %d %d",&be,&en,°);
}
void solve(){
scanf("%d %d",&n,&m);
build_tree(1,n,1);
for(int i=1;i<=m;i++){
int han;
scanf("%d",&han);
if(han==1) han1();
else if(han==0) han0();
else if(han==2) han2();
}
}
int main(){
freopen("asm_command.in","r",stdin);
freopen("asm_command.out","w",stdout);
solve();
return 0;
}