QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#774952#9791. Intrusive Donkeyucup-team5697#WA 1ms12016kbC++233.4kb2024-11-23 14:17:362024-11-23 14:17:36

Judging History

你现在查看的是最新测评结果

  • [2024-11-23 14:17:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:12016kb
  • [2024-11-23 14:17:36]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<vector>
#include<string>
#include<bitset>
#include<numeric>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=2e5+10;
const int N=2e5;
const int INF=0x3f3f3f3f;
const long long LINF=0x3f3f3f3f3f3f3f3f;
int n,q;
char s[MAXN];
#define ll __int128
namespace segtree{
	int L[MAXN<<2],R[MAXN<<2];
	long long siz[MAXN<<2],tag[MAXN<<2];
	#define ls(x) (x<<1)
	#define rs(x) (x<<1|1)
	inline void push_tag(int x,int t){
		tag[x]=min((ll)LINF,(ll)tag[x]*t);
		siz[x]=min((ll)LINF,(ll)siz[x]*t);
	}
	inline void push_up(int x){
		siz[x]=min(LINF,siz[ls(x)]+siz[rs(x)]);
	}
	inline void push_down(int x){
		if(tag[x]^1){
			push_tag(ls(x),tag[x]);
			push_tag(rs(x),tag[x]);
			tag[x]=1;
		}
	}
	void build(int l,int r,int x){
		L[x]=l;
		R[x]=r;
		tag[x]=1;
		if(l==r){
			siz[x]=1;
			return ;
		}
		int mid=(l+r)>>1;
		build(l,mid,ls(x));
		build(mid+1,r,rs(x));
		push_up(x);
	}
	inline void build(){
		build(1,n,1);
	}
	int query_pos(long long pos,int x){
		int l=L[x],r=R[x];
		if(l==r){
			return l;
		}
		push_down(x);
		if(pos<=siz[ls(x)]){
			return query_pos(pos,ls(x));
		}
		else{
			return query_pos(pos-siz[ls(x)],rs(x));
		}
	}
	inline int query_pos(long long pos){
		return query_pos(pos,1);
	}
	long long query(int ql,int qr,int x){
		int l=L[x],r=R[x];
		if(ql<=l&&r<=qr){
			return siz[x];
		}
		if(qr<l||r<ql){
			return 0;
		}
		push_down(x);
		return min(LINF,query(ql,qr,ls(x))+query(ql,qr,rs(x)));
	}
	inline long long query(int l,int r){
		if(l>r){
			return 0;
		}
		return query(l,r,1);
	}
	void modify_pos(int pos,long long val,int x){
		int l=L[x],r=R[x];
		if(l==r){
			siz[x]=val;
			return ;
		}
		push_down(x);
		int mid=(l+r)>>1;
		if(pos<=mid){
			modify_pos(pos,val,ls(x));
		}
		else{
			modify_pos(pos,val,rs(x));
		}
		push_up(x);
	}
	inline void modify_pos(int pos,long long val){
		val=min(val,LINF);
		modify_pos(pos,val,1);
	}
	void modify(int ql,int qr,int x){
		int l=L[x],r=R[x];
		if(ql<=l&&r<=qr){
			push_tag(x,2);
			return ;
		}
		if(qr<l||r<ql){
			return ;
		}
		push_down(x);
		modify(ql,qr,ls(x));
		modify(ql,qr,rs(x));
		push_up(x);
	}
	inline void modify(int l,int r){
		if(l>r){
			return ;
		}
		modify(l,r,1);
	}
}
inline void solve(){
	scanf("%d%d",&n,&q);
	scanf("%s",s+1);
	segtree::build();
	while(q--)
	{
		int opt;
		scanf("%d",&opt);
		if(opt==1){
			long long l,r;
			scanf("%lld%lld",&l,&r);
			int tl=segtree::query_pos(l),tr=segtree::query_pos(r);
			long long sl=segtree::query(1,tl-1),sr=segtree::query(1,tr-1);
			long long vl=segtree::query(tl,tl),vr=segtree::query(tr,tr);
			if(tl==tr){
				segtree::modify(tl,vl+(r-l+1));
				continue;
			}
			segtree::modify_pos(tl,vl+vl-(l-1-sl));
			segtree::modify_pos(tr,vr+(r-sr));
			segtree::modify(tl+1,tr-1);
		}
		else{
			long long p;
			scanf("%lld",&p);
			putchar(s[segtree::query_pos(p)]);
			putchar('\n');
		}
	}
}
signed main(){
	#ifdef LOCAL
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);
	atexit([](){fprintf(stderr,"%.3lfs\n",(double)clock()/CLOCKS_PER_SEC);});
	#endif
	solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 9768kb

input:

4 7
abac
2 2
2 3
1 2 3
2 3
2 4
2 5
2 6

output:

b
a
b
a
a
c

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 9972kb

input:

5 4
shrek
1 1 2
2 7
1 1 7
2 7

output:

k
h

result:

ok 2 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 9724kb

input:

4 7
abac
2 2
2 3
1 2 3
2 3
2 4
2 5
2 6

output:

b
a
b
a
a
c

result:

ok 6 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 9916kb

input:

5 4
shrek
1 1 2
2 7
1 1 7
2 7

output:

k
h

result:

ok 2 lines

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 12016kb

input:

3 55
vfe
1 2 3
1 2 2
1 3 5
2 4
1 1 2
2 9
2 7
2 5
1 10 10
1 1 1
2 9
1 8 12
2 8
1 7 10
2 1
1 5 6
1 1 4
1 20 24
1 14 32
1 19 38
2 48
1 56 64
2 58
2 19
1 64 72
1 36 86
2 11
1 117 124
2 38
2 108
2 85
1 112 118
2 153
2 40
2 114
2 80
1 11 18
2 27
2 73
1 159 162
2 84
1 130 164
2 163
2 65
1 150 156
1 101 109...

output:

f
f
f
f
f
f
v
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
v

result:

wrong answer 2nd lines differ - expected: 'e', found: 'f'