QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#773566#9791. Intrusive Donkeyucup-team3555#WA 1ms5736kbC++201.7kb2024-11-23 09:24:012024-11-23 09:24:03

Judging History

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

  • [2024-11-23 09:24:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5736kb
  • [2024-11-23 09:24:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int N=2e5+5;
int n,m;
string S;

struct Nod{
  int x;
  ll v;
};

namespace SGT{
  #define mid ((l+r)>>1)
  #define lc p<<1
  #define rc p<<1|1
  #define lson l,mid,lc
  #define rson mid+1,r,rc
  
  ll tr[N<<2];
  int tg[N<<2];
  
  void pt(int p,int v){tr[p]=tr[p]*(1ll<<v),tg[p]+=v;}
  void pd(int p){
    if(!tg[p]) return;
    pt(lc,tg[p]),pt(rc,tg[p]),tg[p]=0;
  }
  void pu(int p){tr[p]=tr[lc]+tr[rc];}
  void upd(int l,int r,int p,int x,ll v){
    if(l==r) return tr[p]+=v,void();
    pd(p);
    x<=mid?upd(lson,x,v):upd(rson,x,v);pu(p);
  }
  Nod find(int l,int r,int p,ll v){
    if(l==r) return {l,tr[p]};
    pd(p);
    if(tr[lc]>=v) return find(lson,v);
    auto res=find(rson,v-tr[lc]);
    res.v+=tr[lc];
    return res;
  }
  void build(int l,int r,int p){
    if(l==r) return tr[p]=1,void();
    build(lson),build(rson),pu(p);
  }
  void chg(int l,int r,int p,int x,int y){
    if(x>y||x>r||y<l) return;
    if(x<=l&&y>=r) return pt(p,1);
    pd(p);
    if(x<=mid) chg(lson,x,y);
    if(y>mid) chg(rson,x,y);
    pu(p);
  }
}

int main(){
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>m>>S;
  SGT::build(1,n,1);
  
  while(m--){
    int op,l,r,x;
    cin>>op;
    if(op==1){
      cin>>l>>r;
      auto fi=SGT::find(1,n,1,l),se=SGT::find(1,n,1,r);
      SGT::chg(1,n,1,fi.x+1,se.x);
      if(fi.x==se.x){
        SGT::upd(1,n,1,fi.x,r-l+1);
      }else{
        SGT::upd(1,n,1,fi.x,fi.v-l+1);
        SGT::upd(1,n,1,se.x,se.v-r);
      }
    }else{
      cin>>x;
      auto pos=SGT::find(1,n,1,x);
      cout<<S[pos.x-1]<<'\n';
    }
  }
  return 0;
}

详细

Test #1:

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

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: 5736kb

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: 5676kb

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: 5620kb

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: 0ms
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
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'