QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#220931#4322. rsraogps / 雪に咲く花___WA 1854ms267864kbC++981.6kb2023-10-20 23:39:162023-10-20 23:39:16

Judging History

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

  • [2023-10-20 23:39:16]
  • 评测
  • 测评结果:WA
  • 用时:1854ms
  • 内存:267864kb
  • [2023-10-20 23:39:16]
  • 提交

answer

#include<stdio.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#define N 1000010
#define M 5000010
using namespace std;
#define uint __int128
uint lst[N],lid[N],d[N];
uint a[N],b[N],c[N];
uint anss[M];
vector<pair<int,int> >ed[N];
int n,m;
int gcd(int x,int y){return y==0?x:gcd(y,x%y);}
int read(){
    char ch;int res=0,zf=1;
    while((ch=getchar())<48||ch>57)if(ch=='-')zf=!zf;res=(ch^48);
    while((ch=getchar())>=48&&ch<=57)res=(res<<3)+(res<<1)+(ch^48);
    return zf?res:(-res);
}
uint ask(int x,int nows){
    return lst[x]+d[x]*(uint)(nows-lid[x]);
}
int main(){
    n=read();m=read();
    for(int i=1;i<=n;i++)a[i]=read();
    for(int i=1;i<=n;i++)b[i]=read();
    for(int i=1;i<=n;i++)c[i]=read();
    
    for(int i=1;i<=m;i++){
        int l,r;l=read();r=read();
        ed[r].push_back(make_pair(l,i));
    }
    for(int i=1;i<=n;i++){
        int f=1;
        for(int j=i-1;j>=1;j--){
            uint aa=a[j]&a[j+1];
            uint bb=b[j]|b[j+1];
            uint cc=gcd(c[j],c[j+1]);
            if(aa==a[j]&&bb==b[j]&&cc==c[j]){f=j+1;break;}
            a[j]=aa;b[j]=bb;c[j]=cc;
        }   
        lst[i]=ask(i-1,i-1);
        for(int j=f;j<=i;j++){
            lst[j]=lst[j]+d[j]*(uint)(i-lid[j]-1);
            d[j]=d[j-1]+a[j]*b[j]*c[j];
            lid[j]=i-1;
        }

        for(vector<pair<int,int> >::iterator it=ed[i].begin();it!=ed[i].end();it++){
            anss[it->second]=ask(i,i)-ask(it->first-1,i);
        }
    }
    for(int i=1;i<=m;i++){
        long long q=anss[i];
        printf("%lld\n",q);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1854ms
memory: 267864kb

input:

1000000 4999998
677759 16844 194149 882507 258413 301124 335220 853562 556891 940146 265534 89372 852421 821748 453468 389493 767295 749954 967376 543995 891396 399529 837606 300380 188426 701042 209657 534843 857430 548210 681875 715389 276811 492296 717786 463046 233941 281371 641808 990695 702677...

output:

4342824024213387381
-944145338829206495
-5777725547317140976
3051854759655939423
6238897080720891333
6388725501406050755
-8139887197821258575
-5846348073730257771
5669626024392008369
-4393484242885115233
-8590493229359847932
8566808645331619273
6142830716157790661
3290453531303378686
-47450962459968...

result:

wrong answer 1st lines differ - expected: '3578099829', found: '4342824024213387381'