QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#692066 | #7047. Pot!! | welikestudying | WA | 1ms | 3704kb | C++23 | 1014b | 2024-10-31 13:44:38 | 2024-10-31 13:44:39 |
Judging History
answer
#include<bits/stdc++.h>
#define up(a,b,c)for(int a=b;a<=c;++a)
#define dn(a,b,c)for(int a=b;a>=c;--a)
const int p[]={2,3,5,7},G=44e4;
using namespace std;
int n,q,l,r,x,tb[4][11],lz[G][4],mx[G][4];
string o;
void add(int u,int l,int r,int lb,int rb,int x)
{
if(rb<l||r<lb)return;
if(lb<=l&&r<=rb)
up(i,0,3)mx[u][i]+=tb[i][x],lz[u][i]+=tb[i][x];
else
{
int md=(l+r)/2;
add(u*2,l,md,lb,rb,x),
add(u*2+1,md+1,r,lb,rb,x);
up(i,0,3)mx[u][i]=max(mx[u*2][i],mx[u*2+1][i])+lz[u][i];
}
}
int qry(int i,int u,int l,int r,int lb,int rb)
{
if(rb<l||r<lb)return -G;
if(l<=lb&&rb<=r)return mx[u][i];
int md=(l+r)/2;
return max(qry(i,u*2,l,md,lb,rb),qry(i,u*2+1,md+1,r,lb,rb))+lz[u][i];
}
main()
{
cin>>n>>q;
up(i,0,3)up(j,2,10)
{
int k=j;
while(k%p[i]==0)++tb[i][j],k/=p[i];
}
while(q--)
{
cin>>o>>l>>r;
if(o[1]=='U')cin>>x,add(1,1,n,l,r,x);
else
{
int ans=0;
up(i,0,3)ans=max(ans,qry(i,1,1,n,l,r));
cout<<"ANSWER "<<ans<<'\n';
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3704kb
input:
5 6 MULTIPLY 3 5 2 MULTIPLY 2 5 3 MAX 1 5 MULTIPLY 1 4 2 MULTIPLY 2 5 5 MAX 3 5
output:
ANSWER 1 ANSWER 2
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3580kb
input:
100 1000 MULTIPLY 3 13 8 MULTIPLY 35 86 9 MAX 5 92 MAX 30 86 MAX 4 99 MAX 36 66 MULTIPLY 27 41 5 MAX 21 40 MULTIPLY 5 20 10 MAX 7 98 MAX 10 10 MAX 40 44 MAX 27 47 MAX 37 54 MAX 61 72 MULTIPLY 10 13 8 MAX 19 30 MAX 27 96 MULTIPLY 54 94 9 MAX 29 88 MAX 7 45 MULTIPLY 21 96 7 MULTIPLY 77 98 9 MULTIPLY 3...
output:
ANSWER 3 ANSWER 3 ANSWER 3 ANSWER 3 ANSWER 3 ANSWER 4 ANSWER 4 ANSWER 4 ANSWER 4 ANSWER 4 ANSWER 4 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 8 ANSWER 8 ANSWER 9 ANSWER 11 ANSWER 11 ANSWER 11 ANSWER 11 ANSWER 11 ANSWER 11 ANSWER 11 ANSWER 11 ANSW...
result:
wrong answer 2nd lines differ - expected: 'ANSWER 2', found: 'ANSWER 3'