wsm这题面这么迷呢。。。。
模拟细节好多过艹。。。。
幸好第五种只有俩点有一个还水(雾
注意判重和非法情况(哈戳戳的写了个map去映射操作序列跑的贼慢
#include
using namespace std;
int n,w,ans=-0x3f3f3f3f,tot;
int use[10],que[10];
vector zhanchang[7];
int tianqi[7];
string s1;
map caozuo;
struct player{
struct c{
int type;//1:单位 2:天气 3:反天气 4:烧灼 5:号角
int pos;
int point;
string id;
}card[10];
}a,b;
int Read(){
int i=0,f=1;
char c;
for(c=getchar();(c>'9'||c<'0')&&c!='-';c=getchar());
if(c=='-') f=-1,c=getchar();
for(;c>='0'&&c<='9';c=getchar())
i=(i<<3)+(i<<1)+c-'0';
return i*f;
}
int chupai(int p,int now){
if(p==2){
if(b.card[now].type==1){
zhanchang[b.card[now].pos+3].push_back(b.card[now].point);
}
if(b.card[now].type==2){
tianqi[b.card[now].pos]=tianqi[b.card[now].pos+3]=1;
}
if(b.card[now].type==3){
for(int i=1;i<=3;++i)
tianqi[i]=tianqi[i+3]=0;
}
if(b.card[now].type==4){
int maxx=0;
for(int i=1;i<=6;++i){
if(tianqi[i]) continue;
for(int j=0;j
看着数据范围就知道能O(1)做。。。。
结果少想了特殊情况咕成10pts
#include
using namespace std;
int T,n,m,a,b,c;
int Read(){
int i=0,f=1;
char c;
for(c=getchar();(c>'9'||c<'0')&&c!='-';c=getchar());
if(c=='-')
f=-1,c=getchar();
for(;c>='0'&&c<='9';c=getchar())
i=(i<<3)+(i<<1)+c-'0';
return i*f;
}
int main(){
T=Read();
while(T--){
n=Read(),m=Read(),a=Read(),b=Read(),c=Read();
c=c%(n-2)+2;
if(c==2&&m==1)puts("-1");
else cout<<(n-1)+(m+1)/2<<'\n';
}
}
抱着一颗想开1e18的线段树的心打了40pts暴力==
结果打着打着比赛结束了(%你害人不浅啊
正解二分左右端点所在块,开两颗线段树维护就好了
#include
using namespace std;
#define LL long long
const int N=5e5+5;
const LL Mod=1e8+7;
int n,c;
LL lastans;
struct Tree{
int l,r;
LL len,maxh;
}tr[N<<2];
LL Read(){
LL i=0,f=1;
char c;
for(c=getchar();(c>'9'||c<'0')&&c!='-';c=getchar());
if(c=='-') f=-1,c=getchar();
for(;c>='0'&&c<='9';c=getchar())
i=(i<<3)+(i<<1)+c-'0';
return i*f;
}
#define lc (root<<1)
#define rc (root<<1|1)
void build(int root,int l,int r){
tr[root].l=l;
tr[root].r=r;
if(l==r){
tr[root].len=0ll;
return;
}
int mid=(l+r)>>1;
build(lc,l,mid);
build(rc,mid+1,r);
}
void push_up(int root){
tr[root].len=tr[lc].len+tr[rc].len;
tr[root].maxh=max(tr[lc].maxh,tr[rc].maxh);
}
void update(int root,int k,LL len,int h){
if(tr[root].l==tr[root].r){
tr[root].len=len;
tr[root].maxh=h;
return ;
}
if(k<=tr[lc].r)
update(lc,k,len,h);
else
update(rc,k,len,h);
push_up(root);
}
LL query(int root,LL k,int type){
if(tr[root].l==tr[root].r){
if(type==0){
if(k==0)
return tr[root].l-1;
else
return tr[root].l;
}
else
return tr[root].l;
}
if(k>=tr[lc].len)
return query(rc,k-tr[lc].len,type);
else
return query(lc,k,type);
}
LL find(int root,int l,int r){
if(tr[root].l>=l&&tr[root].r<=r){
return tr[root].maxh;
}
LL res=0;
if(tr[lc].r>=l)
res=max(res,find(lc,l,r));
if(tr[rc].l<=r)
res=max(res,find(rc,l,r));
return res;
}
LL rel(LL x){
return (x*2333+lastans*666)%Mod+1;
}
int main(){
n=Read(),c=Read();
build(1,1,n);
int now=0;
for(int i=1;i<=n;++i){
int cz=Read();
if(cz==1){
LL len=Read();
LL h=Read();
if(c==1){
len=rel(len);
h=rel(h);
}
update(1,++now,len,h);
}
else{
if(cz==2){
int x=Read();
update(1,x,0,0);
}
else{
LL L=Read(),R=Read(),l,r;
l=query(1,L,0),r=query(1,R,1);
lastans=find(1,l,r);
cout<