QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#358271#8225. 最小值之和dengtingyu0 2ms11716kbC++141.7kb2024-03-19 18:38:362024-03-19 18:38:36

Judging History

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

  • [2024-03-19 18:38:36]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:11716kb
  • [2024-03-19 18:38:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 81
ll n,a[N];
ll f[N][N][N],pos[N][N][N];
ll len;
inline void push(ll *x,ll *y,ll u,ll v){
    if(x[u%len]>u)return ;x[u%len]=u;y[u%len]=v;
    return ;
}
inline bool pd(ll *x,ll y,ll l){return y<=x[y%l];}
inline void suan(ll l,ll r,ll x,ll p){
    if(l==r)return ;
    ll g=pos[l][r][x%(r-l)];
    ll u=(f[l][r][x%(r-l)]-x)/(r-l);
    x+=u*(r-l);p+=u;
    suan(l,g,x,p);
    cout<<p<<' ';
    suan(g+1,r,x,p);
    return ;
}
int main(){
//    freopen("test1.in","r",stdin);
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;for(int i=1;i<=n;i++)cin>>a[i];
    memset(f,-1,sizeof(f));
    for(int i=1;i<=n;i++){if(a[i]==a[i+1])f[i][i+1][0]=a[i];pos[i][i+1][0]=i;}
    for(int i=3;i<=n;i++){
        for(int l=1;l+i-1<=n;l++){
            ll r=l+i-1;len=r-l;
            auto &u=f[l][r],&v=pos[l][r];
            if(pd(f[l][r-1],a[r],len-1))push(u,v,a[r],r-1);
            if(pd(f[l+1][r],a[l],len-1))push(u,v,a[l],l);
            for(int j=l+1;j<r-1;j++){
                ll q=j-l,p=r-j-1;ll tem=p*q/__gcd(p,q);
                for(int k=0;k<tem;k++){
                    ll tt=min(f[l][j][k%q],f[j+1][r][k%p]);
                    if(f[l][j][k%q]==-1||f[j+1][r][k%p]==-1||k>tt)continue;
                    ll o=k+(tt-k)/tem*tem;for(int t=1;t<=r-l&&o>0;t++){
                        push(u,v,o,j);o-=tem;
                    }
                }
            }//cout<<l<<' '<<r<<'\n';
//        	for(int k=0;k<r-l;k++)cout<<k<<' '<<f[l][r][k]<<' ';cout<<'\n';
        }
    }if(!pd(f[1][n],0,n)){cout<<"No";return 0;}
    cout<<"Yes"<<'\n';
    suan(1,n,0,0);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 11
Accepted
time: 0ms
memory: 8860kb

input:

5
14 14 12 13 13

output:

Yes
5 3 3 4 

result:

ok The answer is correct.

Test #2:

score: 0
Accepted
time: 0ms
memory: 9900kb

input:

5
4 4 7 7 4

output:

Yes
1 1 4 1 

result:

ok The answer is correct.

Test #3:

score: 0
Accepted
time: 1ms
memory: 8816kb

input:

5
4 13 14 14 13

output:

Yes
1 4 5 4 

result:

ok The answer is correct.

Test #4:

score: 0
Accepted
time: 1ms
memory: 8424kb

input:

5
11 11 10 5 5

output:

Yes
5 4 1 2 

result:

ok The answer is correct.

Test #5:

score: 0
Accepted
time: 2ms
memory: 11716kb

input:

5
10 10 10 4 4

output:

Yes
4 4 1 1 

result:

ok The answer is correct.

Test #6:

score: 0
Accepted
time: 0ms
memory: 7804kb

input:

5
20 20 17 7 4

output:

Yes
10 7 2 1 

result:

ok The answer is correct.

Test #7:

score: 0
Accepted
time: 1ms
memory: 9280kb

input:

5
12 12 16 19 19

output:

Yes
3 3 5 8 

result:

ok The answer is correct.

Test #8:

score: -11
Wrong Answer
time: 0ms
memory: 9196kb

input:

5
2 2 6 11 11

output:

No

result:

wrong answer Line 1 expected 

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%