QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#774613 | #9791. Intrusive Donkey | ucup-team1004# | WA | 1ms | 5912kb | C++14 | 1.6kb | 2024-11-23 13:33:02 | 2024-11-23 13:33:04 |
Judging History
answer
#include<bits/stdc++.h>
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
using namespace std;
typedef long long ll;
const int N=2e5+10;
namespace seg
{
ll t[N<<2],tag[N<<2];
void build(int l,int r,int now)
{
t[now]=r-l+1,tag[now]=1;
if(l!=r) build(l,mid,ls),build(mid+1,r,rs);
}
void Tag(int now,ll a)
{
tag[now]*=a,t[now]*=a;
}
void push_down(int now)
{
Tag(ls,tag[now]),Tag(rs,tag[now]);
tag[now]=1;
}
void update(int now)
{
t[now]=(t[ls]+t[rs])*tag[now];
}
void modify(int l,int r,int now,int L,int R)
{
if(l>R||r<L) return;
if(L<=l&&r<=R) return Tag(now,2);
push_down(now);
modify(l,mid,ls,L,R),modify(mid+1,r,rs,L,R);
update(now);
}
void modify1(int l,int r,int now,int w,ll a)
{
if(l==r) return t[now]+=a,void();
if(w<=mid) modify1(l,mid,ls,w,a);
else modify1(mid+1,r,rs,w,a);
update(now);
}
pair<int,ll> query(int l,int r,int now,ll a)
{
if(l==r) return {l,a};
push_down(now);
if(t[ls]<a) return query(mid+1,r,rs,a-t[ls]);
else return query(l,mid,ls,a);
}
}
char str[N];
int n,Q,op;
int main()
{
scanf("%d%d%s",&n,&Q,str+1);
seg::build(1,n,1);
while(Q--)
{
scanf("%d",&op);
ll l,r,x;
if(op==1)
{
scanf("%lld%lld",&l,&r);
auto k1=seg::query(1,n,1,l),k2=seg::query(1,n,1,r+1);
int L=k1.first,R=k2.first-1;
if(L<=R) seg::modify(1,n,1,L,R);
seg::modify1(1,n,1,L,-(k1.second-1)),seg::modify1(1,n,1,R+1,k2.second-1 );
}
else
{
scanf("%lld",&x);
printf("%c\n",str[seg::query(1,n,1,x).first]);
}
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5876kb
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: 1ms
memory: 5792kb
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: 1ms
memory: 5848kb
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: 5912kb
input:
5 4 shrek 1 1 2 2 7 1 1 7 2 7
output:
k h
result:
ok 2 lines
Test #5:
score: 0
Accepted
time: 1ms
memory: 5832kb
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 e f f f f v f e f f f e e e f e e f e e e f e f e v
result:
ok 27 lines
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 5876kb
input:
60 51 ranhfkbjhkxckkcbhgsspsjcbjgpwcfvmqqlvlfualndmqqsihsfdyqviowu 2 53 2 37 2 33 2 60 1 1 32 2 44 1 87 92 1 7 77 1 56 86 2 17 1 128 184 1 26 159 2 323 2 55 1 24 316 1 435 652 2 316 2 444 1 819 868 2 27 2 912 2 313 1 555 576 1 510 942 1 1118 1269 2 365 2 84 1 595 650 2 1468 2 258 1 1557 1607 2 938 1...
output:
d v m u s k l c p g j m p j c l s c b p l p f m p g
result:
wrong answer 7th lines differ - expected: 'q', found: 'l'