QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#382983#7782. Ursa MinorGraphcityTL 2619ms376456kbC++203.1kb2024-04-08 20:42:182024-04-08 20:42:19

Judging History

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

  • [2024-04-08 20:42:19]
  • 评测
  • 测评结果:TL
  • 用时:2619ms
  • 内存:376456kb
  • [2024-04-08 20:42:18]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int Maxn=2e5+2,B=448;
const int base=19260817,Mod=1e9+7;

inline int Pow(int x,int y)
{
    int res=1;
    while(y)
    {
        if(y&1) res=1ll*res*x%Mod;
        x=1ll*x*x%Mod,y>>=1;
    }
    return res;
}

int n,m,q,a[Maxn+5],b[Maxn+5],st[Maxn+5][20],pw[Maxn+5];
int L[Maxn+5],R[Maxn+5],idx[Maxn+5],iv[Maxn+5],tot;
inline int Get(int l,int r)
{int len=__lg(r-l+1); return __gcd(st[l][len],st[r-(1<<len)+1][len]);}

struct Block
{
    int sum[B+5],a[Maxn+5];
    inline void Upd(int x,int y)
    {sum[idx[x]]=(1ll*sum[idx[x]]-a[x]+y+Mod)%Mod,a[x]=y;}
    inline int Count(int x)
    {
        if(x==0) return 0;
        int res=0; For(i,1,idx[x]-1) res=(res+sum[i])%Mod;
        For(i,L[idx[x]],x) res=(res+a[i])%Mod; return res;
    }
} T[B+2];

struct Fenwick
{
    int sum[Maxn+5],pr[Maxn+5],a[Maxn+5];
    inline void Upd(int x,int y)
    {
        int dlt=(y-a[x]+Mod)%Mod; a[x]=y;
        For(i,x,R[idx[x]]) pr[i]=(pr[i]+dlt)%Mod;
        For(i,idx[x],tot) sum[i]=(sum[i]+dlt)%Mod;
    }
    inline int Count(int x) {return x==0?0:(sum[idx[x]-1]+pr[x])%Mod;}
} F;

struct BIT
{
    int t[Maxn+5];
    #define lowbit(x) (x&-x)
    inline void Add(int x,int y) {while(x<=n) t[x]=(t[x]+y)%Mod,x+=lowbit(x);}
    inline int Count(int x) {int res=0; while(x) res=(res+t[x])%Mod,x-=lowbit(x); return res;}
} BT;

int main()
{
    // freopen("1.in","r",stdin);

    ios::sync_with_stdio(false);
    cin>>n>>m>>q; For(i,1,n) cin>>a[i];
    pw[0]=1; For(i,1,Maxn) pw[i]=1ll*pw[i-1]*base%Mod;
    iv[0]=1; For(i,1,Maxn) iv[i]=Pow(pw[i],Mod-2);
    For(i,1,m) cin>>b[i],st[i][0]=b[i];
    For(j,1,19) for(int i=1;i+(1<<j)-1<=m;++i)
        st[i][j]=__gcd(st[i][j-1],st[i+(1<<j-1)][j-1]);
    for(int i=1;i<=n;i+=B) L[++tot]=i,R[tot]=min(n,i+B-1);
    For(i,1,tot) For(j,L[i],R[i]) idx[j]=i;
    For(i,1,n) For(j,1,B) T[j].Upd(i,1ll*a[i]*pw[i%j]%Mod);
    For(i,1,n) BT.Add(i,a[i]),F.Upd(i,1ll*a[i]*pw[i]%Mod);
    int it=0; while(q--)
    {
        char ch; int l,r,x,y; cin>>ch;
        if(ch=='U')
        {
            cin>>x>>y; BT.Add(x,(y-a[x]+Mod)%Mod),a[x]=y;
            For(i,1,B) T[i].Upd(x,1ll*y*pw[x%i]%Mod);
            F.Upd(x,1ll*y*pw[x]%Mod);
        }
        if(ch=='Q')
        {
            cin>>l>>r>>x>>y; int k=__gcd(Get(x,y),r-l+1);
            int sum=(BT.Count(r)-BT.Count(l-1)+Mod)%Mod;
            sum=1ll*sum*Pow(k,Mod-2)%Mod;
            sum=1ll*sum*(pw[k]-1)%Mod*Pow(base-1,Mod-2)%Mod;
            int all=0;
            if(k<=B) all=(T[k].Count(r)-T[k].Count(l-1)+Mod)%Mod;
            else
            {
                For(i,0,n/k)
                {
                    int a=i*k,b=(i+1)*k-1; a=max(a,l),b=min(b,r);
                    if(a<=b)
                    {
                        int now=(F.Count(b)-F.Count(a-1)+Mod)%Mod;
                        all=(all+1ll*now*iv[i*k]%Mod)%Mod;
                    }
                }
            }
            puts(sum==all?"Yes":"No");
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 26ms
memory: 7920kb

input:

6 4 5
1 1 4 5 1 4
3 3 2 4
Q 1 5 1 2
Q 2 5 3 4
U 5 2
Q 1 6 1 2
Q 2 5 3 4

output:

Yes
No
No
Yes

result:

ok 4 tokens

Test #2:

score: 0
Accepted
time: 27ms
memory: 7768kb

input:

1 1 1
0
1
Q 1 1 1 1

output:

Yes

result:

ok "Yes"

Test #3:

score: 0
Accepted
time: 498ms
memory: 11620kb

input:

2000 2000 200000
1 1 2 0 0 2 0 2 0 0 0 0 0 2 2 1 2 0 0 2 2 2 1 0 1 2 1 2 0 0 1 1 1 2 0 0 2 2 2 2 0 2 0 0 2 1 2 0 0 1 2 2 1 0 2 0 0 0 1 2 2 1 2 2 0 0 1 1 1 0 0 2 0 0 1 1 0 2 2 2 1 0 0 1 0 1 2 2 2 1 1 2 2 1 2 1 0 2 2 3 1 3 2 3 1 0 1 2 0 1 1 1 0 2 2 3 2 0 3 2 3 3 1 2 3 1 2 0 1 0 3 1 0 0 2 0 1 2 1 3 2 2...

output:

Yes
Yes
No
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
Yes
Yes
No
No
No
No
No
Yes
No
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No...

result:

ok 100554 tokens

Test #4:

score: 0
Accepted
time: 292ms
memory: 24264kb

input:

1 200000 200000
998244353
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 100240 tokens

Test #5:

score: 0
Accepted
time: 271ms
memory: 18604kb

input:

6 131072 200000
0 0 0 0 1000000000 1000000000
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...

output:

Yes
Yes
Yes
No
No
No
Yes
No
No
No
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
No
No
No
No
No
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
Yes
Yes
No
Yes
N...

result:

ok 100021 tokens

Test #6:

score: 0
Accepted
time: 1638ms
memory: 376384kb

input:

200000 200000 200000
490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
Yes
Yes
Yes
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
Yes
No
No
No
No
No
No
No
No
N...

result:

ok 187340 tokens

Test #7:

score: 0
Accepted
time: 1515ms
memory: 376344kb

input:

200000 200000 200000
360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 199985 tokens

Test #8:

score: 0
Accepted
time: 1581ms
memory: 376380kb

input:

200000 200000 200000
793134805 922104801 158394038 993313213 77527653 992889267 148461787 499165677 132176015 189185554 783374975 332147281 923925325 371040161 393285793 437388761 138662855 212488140 265392646 498903298 578518594 550390771 960084339 408548934 56106823 814997309 456913457 300689692 1...

output:

No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No...

result:

ok 200000 tokens

Test #9:

score: 0
Accepted
time: 1493ms
memory: 376456kb

input:

200000 200000 200000
451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037...

output:

No
No
No
No
Yes
No
Yes
No
No
No
No
Yes
No
No
No
Yes
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
Yes
No
No
Yes
No
Yes
No
Yes
No
Yes
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
Yes
No
Yes
No
No
No
No
Yes
No
Yes
No
No
Yes
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
N...

result:

ok 199977 tokens

Test #10:

score: 0
Accepted
time: 1593ms
memory: 376432kb

input:

200000 200000 200000
606894463 710609424 913364361 30426550 801940265 516097169 349718376 606894463 710609424 913364361 30426550 801940265 516097169 349718376 606894463 710609424 913364361 30426550 801940265 516097169 349718376 606894463 710609424 913364361 30426550 801940265 516097169 349718376 606...

output:

No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
N...

result:

ok 100329 tokens

Test #11:

score: 0
Accepted
time: 2468ms
memory: 376300kb

input:

200000 199999 200000
903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886...

output:

Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No...

result:

ok 100000 tokens

Test #12:

score: 0
Accepted
time: 2545ms
memory: 376424kb

input:

199997 199989 199999
516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047...

output:

Yes
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
Yes
No
Yes
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
Yes
No
No
No
No
Yes
No
Yes
No
Yes
Yes
Yes
No
Yes
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
No
Yes
Yes
No
Yes
No
No
No
No
No
No
No
Yes
No...

result:

ok 100000 tokens

Test #13:

score: 0
Accepted
time: 2619ms
memory: 376356kb

input:

200000 199899 200000
738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100...

output:

Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No...

result:

ok 100000 tokens

Test #14:

score: 0
Accepted
time: 2429ms
memory: 376440kb

input:

200000 199990 200000
748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491...

output:

Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No...

result:

ok 100000 tokens

Test #15:

score: 0
Accepted
time: 1123ms
memory: 376344kb

input:

200000 200000 200000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 200000 tokens

Test #16:

score: 0
Accepted
time: 1147ms
memory: 376296kb

input:

200000 200000 200000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 200000 tokens

Test #17:

score: 0
Accepted
time: 1615ms
memory: 376240kb

input:

200000 200000 200000
136241709 121069654 74104428 402269028 289305416 855066384 59173243 188019353 669781180 986996513 504339812 329791320 25125974 222565943 288337442 964609791 466878029 264002600 189175389 9157365 469615339 896075603 753652692 122288279 240727003 784469217 906985969 890794301 2169...

output:


result:

ok 0 tokens

Test #18:

score: 0
Accepted
time: 1376ms
memory: 376424kb

input:

200000 200000 200000
273240622 378627620 579491720 693306037 632472065 511340335 670989889 554488479 652467925 278524470 836147563 424777678 759339952 855362660 230757613 865543002 560326470 755302163 785969817 6168093 585297358 945522008 799833815 740595138 24393108 602846463 227643614 845760733 81...

output:


result:

ok 0 tokens

Test #19:

score: 0
Accepted
time: 1614ms
memory: 376356kb

input:

200000 200000 200000
902784461 118694875 998774623 411874728 685597851 368044897 72498166 42228570 960589282 760858636 63223215 20140256 256927497 432494553 374529608 902188891 898994 969710880 697644219 743838599 684197754 515142816 492082738 409457048 326043554 219156706 376310102 878117528 358651...

output:


result:

ok 0 tokens

Test #20:

score: -100
Time Limit Exceeded

input:

200000 200000 200000
658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584...

output:

Yes
No
Yes
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
Yes
No
Yes
Yes
No
No
Yes
No
No
No
No
No
Yes
Yes
No
No
No
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
No
No
No
No
No
No
Yes
No
No
No
No
No
Yes
No
No
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
No
No
No
No
Yes
No
No
No
No
Yes
Yes
No
Yes
No
Yes
No
Yes
No
No
No
Ye...

result: