QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#648107#4322. rsraogps / 雪に咲く花ccccccydWA 1581ms133588kbC++141.7kb2024-10-17 17:03:562024-10-17 17:03:58

Judging History

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

  • [2024-10-17 17:03:58]
  • 评测
  • 测评结果:WA
  • 用时:1581ms
  • 内存:133588kb
  • [2024-10-17 17:03:56]
  • 提交

answer

#include<bits/stdc++.h>
#define ll unsigned int
#define ph emplace_back
#define rep(i,l,r) for(int i(l),i##end(r);i<=i##end;++i)
#define per(i,r,l) for(int i(r),i##end(l);i>=i##end;--i)
using namespace std;
template<typename T>
inline void read(T &x){//保证无负数!!!
    char c; while(!isdigit(c=getchar())); 
    x=(c^48); while(isdigit(c=getchar())) x=(x<<1)+(x<<3)+(c^48);
}
template<typename Tx,typename ...Ty>
inline void read(Tx& x,Ty& ...y){
    read(x),read(y...);
}

template<typename T>
inline void write(T x){
    if(x>9) write(x/10);
    putchar('0'+x%10);
}
inline void write(int x,char c){
    write(x),putchar(c);
}

const int N=1e6+20,M=5e6+20;
inline ll gcd(ll x,ll y){ return y?gcd(y,x%y):x; }
int n,m,ql[M]; ll ans[M],a[N],b[N],c[N],sw[N],r[N],sr[N]; vector<int> q[N];
ll qry(int i,int x){ return sr[x]+i*sw[x]; }
signed main(){
    // freopen("1.in","r",stdin);
    read(n,m);
    rep(i,1,n) read(a[i]);
    rep(i,1,n) read(b[i]);
    rep(i,1,n) read(c[i]);
    rep(i,1,m){
        int r; read(ql[i],r);
        q[r].ph(i);
    }
    rep(i,1,n){
        int k=i-1;
        while(k&&((a[k]&a[i])!=a[k]||(b[k]|b[i])!=b[k]||gcd(c[k],c[i])!=c[k])) k--;
        rep(j,k+1,i){
            r[j]+=(j==i?0:a[j]*b[j]*c[j]*(i-1));//之前的
            a[j]&=a[i],b[j]|=b[i],c[j]=gcd(c[j],c[i]);
            sw[j]=sw[j-1]+a[j]*b[j]*c[j],r[j]-=a[j]*b[j]*c[j]*(i-1);
            sr[j]=sr[j-1]+r[j];
            // cerr<<a[j]*b[j]*c[j]<<' '<<sw[j]<<' '<<r[j]<<' '<<sr[j]<<'\n';
        } 
        // rep(j,1,i) cerr<<qry(i,j)<<' '; cerr<<'\n';
        for(int j:q[i]) ans[j]=qry(i,i)-qry(i,ql[j]-1);
    }
    rep(i,1,m) write(ans[i],'\n');
    return 0;
}//g++ -g L.cpp -o my -std=c++14 -Wall

详细

Test #1:

score: 0
Wrong Answer
time: 1581ms
memory: 133588kb

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:

)
247368737
(
123772255
+
/
1981625521
/
-
'
446408196
-
2146535877
(
'
861849275
/
926506509
652453278
'
*
1597517111
.
,
(
548698842
2016320224
,
-
.
1893213051
)
1967347591
625706668
.
1430346257
.
409927353
)
2127121158
-
)
1555348103
1557706737
127616886
'
+
64312248
1000746764
'
1079580524
110...

result:

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