QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#90136 | #5100. 卡牌游戏 | XZTmaxsmall67 | Compile Error | / | / | C++14 | 3.1kb | 2023-03-22 13:40:47 | 2023-03-22 13:40:49 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-03-22 13:40:49]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-03-22 13:40:47]
- 提交
answer
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define int long long
using namespace std;
const int N=5e5+100,M=sqrt(N)+10,inf=1e9+7;
int n,S,tp,id,BB;
int A[N],B[N],ans[N<<1];
int a[N],b[N],GCD[M][M],LCM[M][M],Get[N];
//get[i] 表示 <=S 的最大的 i 的倍数
namespace G
{
pii g1[N],g2[N];
void clear(){for(int i=0;i<N;i++)g1[i]=g2[i]=make_pair(-inf,0);}
void push(int x,int v,int i){pii res(v,i);for(int y=x;y<=S;y+=x)if(g1[y]<res)g2[y]=g1[y],g1[y]=res;}
int get(int x){int t=0;for(int y=x;y<=S;y+=x)t=max(t,g1[y].fi+y);return t;}
}
//namespace CT
//{
// int a[N];
// void build(int n){memset(a,0,sizeof(a));}
// void update(int l,int r,int v){for(int i=l;i<=r;i++)a[i]=max(a[i],v);}
// void query(int*ans){for(int i=1;i<=n;i++)ans[i]=max(ans[i],a[i]);}
//}
namespace CT//CatTree
{
int n;
int cnt[N<<1];
int pre[N<<1][21],nxt[N<<1][21];//前缀,后缀
void build(int _n)
{
n=1;while(n<_n)n<<=1;
cnt[0]=-1;for(int i=1;i<=n;i++)cnt[i]=cnt[i>>1]+1;
}
void update(int l,int r,int v)
{
if(l>r||v<0)return;int d=cnt[r-l+1];
pre[l][d]=max(pre[l][d],v);nxt[r][d]=max(nxt[r][d],v);
if(l/(1<<d)+2==r/(1<<d))nxt[l/(1<<d)+(1<<d)][d]=max(nxt[l/(1<<d)+(1<<d)][d],v);
}
void query(int *a)
{
for(int i=0;i<=cnt[n];i++)
for(int j=1;j<=n;j+=(1<<i))
{
for(int k=j+1;k<j+(1<<i);k++)pre[k][i]=max(pre[k][i],pre[k-1][i]);
for(int k=j+(1<<i)-2;k>=j;k--)nxt[k][i]=max(nxt[k][i],nxt[k+1][i]);
for(int k=j;k<j+(1<<i);k++)a[k]=max({a[k],pre[k][i],nxt[k][i]});
}
}
}
int lcm(int x,int y){return x<=BB&&y<=BB?LCM[x][y]:x/__gcd(x,y)*y;}
void getF(int*a,int*f)
{
G::clear();
for(int i=1;i<=n;i++,f[i]=max(f[i],f[i-1]))
if(a[i]<=BB)
{
for(int j=i-1,cnt=1+(a[j]<=BB);j>=1&&cnt<=3;j--,cnt+=a[j]<=BB)f[i]=max(f[i],f[j]+Get[lcm(a[i],a[j])]);
for(int j=i+1,cnt=1+(a[j]<=BB);j<=n&&cnt<=3;j++,cnt+=a[j]<=BB)f[j]=max(f[j],f[i]+Get[lcm(a[i],a[j])]);
}
else f[i]=max(f[i],G::get(a[i])),G::push(a[i],f[i],i);
}
signed main()
{
scanf("%lld%lld%lld%lld",&n,&S,&tp,&id);BB=sqrt(S);
for(int i=1;i<=n;i++)scanf("%lld",&a[i]),a[i]=min(a[i],S+1);
for(int i=1;i<=BB;i++)for(int j=1;j<=BB;j++)GCD[i][j]=__gcd(i,j),LCM[i][j]=i*j/GCD[i][j];
for(int i=1;i<=S;i++)Get[i]=S/i*i;
getF(a,A);reverse(a+1,a+n+1);getF(a,B);A[0]=A[n+1]=B[0]=B[n+1]=0;
reverse(B+1,B+n+1);reverse(a+1,a+n+1);
printf("%lld ",A[n]);if(!tp)return 0;
return 0;
CT::build(n);G::clear();
for(int i=1;i<=n;i++)
if(a[i]<=BB)
{
for(int j=i-1,cnt=1+(a[j]<=BB);j>=1&&cnt<=3;j--,cnt+=a[j]<=BB)CT::update(j+1,i-1,A[j]+B[i]+Get[lcm(a[i],a[j])]);
for(int j=i+1,cnt=1+(a[j]<=BB);j<=n&&cnt<=3;j++,cnt+=a[j]<=BB)CT::update(i+1,j-1,A[i]+B[j]+Get[lcm(a[i],a[j])]);
}
else
{
for(int y=a[i];y<=S;y+=a[i])CT::update(G::g1[y].se+1,i-1,G::g1[y].fi+B[i]+y),CT::update(G::g2[y].se+1,i-1,G::g2[y].fi+B[i]+y);
G::push(a[i],A[i],i);
}
CT::query(ans);
ll res=0;
for(int i=1;i<=n;i++)ans[i]=max({ans[i],A[i-1]+B[i+1]}),res^=(1ll)*i*ans[i];
// for(int i=1;i<=n;i++)printf("%lld ",ans[i]);puts("SB");
printf("%lld\n",res);
return 0;
}
详细
answer.code: In function ‘int main()’: answer.code:91:9: error: ‘ll’ was not declared in this scope 91 | ll res=0; | ^~ answer.code:92:65: error: ‘res’ was not declared in this scope 92 | for(int i=1;i<=n;i++)ans[i]=max({ans[i],A[i-1]+B[i+1]}),res^=(1ll)*i*ans[i]; | ^~~ answer.code:94:25: error: ‘res’ was not declared in this scope 94 | printf("%lld\n",res); | ^~~ answer.code:70:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 70 | scanf("%lld%lld%lld%lld",&n,&S,&tp,&id);BB=sqrt(S); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:71:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 71 | for(int i=1;i<=n;i++)scanf("%lld",&a[i]),a[i]=min(a[i],S+1); | ~~~~~^~~~~~~~~~~~~~