QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#773516 | #9791. Intrusive Donkey | ucup-team4454# | WA | 1ms | 5876kb | C++14 | 2.2kb | 2024-11-23 09:13:16 | 2024-11-23 09:13:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(){
ll ret=0,flg=0;
char c=getchar();
while(c<'0'||c>'9')flg|=c=='-',c=getchar();
while(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',c=getchar();
return flg?-ret:ret;
}
inline void write(ll x,bool flg){
char a[21];
if(!x)putchar('0');
if(x<0)putchar('-'),x=-x;
int cnt=0;
while(x){
a[++cnt]=x%10+'0';
x/=10;
}
while(cnt)putchar(a[cnt--]);
putchar(flg?'\n':' ');
return ;
}
#define maxn 400100
char s[maxn];
ll sum[maxn<<2],a[maxn];
int n,q;
const ll inf=1e18+10;
void build(int l,int r,int p){
if(l==r)return sum[p]=a[l],void();
int mid(l+r>>1);
build(l,mid,p<<1);
build(mid+1,r,p<<1|1);
sum[p]=sum[p<<1]+sum[p<<1|1];
return ;
}
void modify(int l,int r,int x,int p){
if(l==r)return sum[p]=min(a[x],inf),void();
int mid(l+r>>1);
if(x<=mid)modify(l,mid,x,p<<1);
else modify(mid+1,r,x,p<<1|1);
sum[p]=sum[p<<1]+sum[p<<1|1];
sum[p]=min(sum[p],inf);
return ;
}
int query(int l,int r,ll x,int p){
if(l==r)return l;
int mid(l+r>>1);
if(x<=sum[p<<1])return query(l,mid,x,p<<1);
else return query(mid+1,r,x-sum[p<<1],p<<1|1);
}
ll preS(int l,int r,int k,int p){
if(r<=k)return sum[p];
if(k<l)return 0;
int mid(l+r>>1);
return preS(l,mid,k,p<<1)+preS(mid+1,r,k,p<<1|1);
}
int main(){
n=read(),q=read();
scanf("%s",s+1);
for(int i=1;i<=n;i++)a[i]=1;
build(1,n,1);
// cout<<"??"<<endl;
while(q--){
ll tp=read(),l,r;
if(tp==1){
l=read(),r=read();
ll x=query(1,n,l,1),y=query(1,n,r,1);
for(int i=x+1;i<y;i++){
a[i]*=2;
modify(1,n,i,1);
}
if(x==y){
a[x]+=r-l+1;
modify(1,n,x,1);
}else{
ll v1=preS(1,n,x-1,1),v2=preS(1,n,y-1,1);
a[x]+=v1+a[x]-l+1;
modify(1,n,x,1);
a[y]+=r-v2;
modify(1,n,y,1);
}
}else{
l=read();
putchar(s[query(1,n,l,1)]);
puts("");
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5816kb
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: 5796kb
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: 5808kb
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: 1ms
memory: 5876kb
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: 5656kb
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: 5760kb
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 u c b u j u c p c u s u b u u u u u u u
result:
wrong answer 7th lines differ - expected: 'q', found: 'u'