QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#412726#8225. 最小值之和do_while_true0 2ms9760kbC++203.6kb2024-05-16 18:39:012024-05-16 18:39:01

Judging History

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

  • [2024-05-16 18:39:01]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:9760kb
  • [2024-05-16 18:39:01]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<ctime>
#include<random>
#include<array>
#include<assert.h>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n'
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n'
#define DE(fmt,...) fprintf(stderr, "Line %d : " fmt "\n",__LINE__,##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef pair<int,ll>pil;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
int cmax(int &x,int y){
	if(x<y){
		x=y;
		return 1;
	}
	return 0;
}
template<typename T>
T &read(T &r){
	r=0;bool w=0;char ch=getchar();
	while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
	while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
	return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x,T2& ...y){read(x);read(y...);}
const int mod=998244353;
inline void cadd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
inline void cdel(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
inline int del(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
int qpow(int x,int y){
	int s=1;
	while(y){
		if(y&1)s=1ll*s*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return s;
}
const int N=81;
int n;
int a[N],b[N];
int f[N][N][N];
int pos[N][N][N],val[N][N][N];
int solve(int i,int j,int len1,int len2,int o){
	for(int w=0;w<o;w++)
		if(w%len1==i&&w%len2==j)
			return w;
	return 0x7fffffff;
}
void dfs(int l,int r,int k,int h){
	// DE("%d %d %d",l,r,k);
	if(l+1==r){
		b[l]=a[l]-k+h;
		return ;
	}
	if(pos[l][r][k%(r-l)]==l){
		b[l]=(a[l]-k)/(r-l)+h;
		dfs(l+1,r,k+(b[l]-h)*(r-l),b[l]);
		return ;
	}
	if(pos[l][r][k%(r-l)]==r){
		b[r-1]=(a[r]-k)/(r-l)+h;
		dfs(l,r-1,k+(b[r-1]-h)*(r-l),b[r-1]);
		return ;
	}
	int mid=pos[l][r][k%(r-l)];
	b[mid]=(f[l][r][k%(r-l)]-k)/(r-l)+h;
	dfs(l,mid,k+(b[mid]-h)*(r-l),b[mid]);
	dfs(mid+1,r,k+(b[mid]-h)*(r-l),b[mid]);
}
signed main(){
	#ifdef do_while_true
//		assert(freopen("data.in","r",stdin));
//		assert(freopen("data.out","w",stdout));
	#endif
	read(n);
	memset(f,-1,sizeof(f));
	for(int i=1;i<=n;i++)read(a[i]);
	for(int i=1;i<n;i++){
		if(a[i]==a[i+1])f[i][i+1][0]=a[i];
	}
	for(int len=3;len<=n;len++){
		for(int l=1;l+len-1<=n;l++){
			int r=l+len-1;
			for(int k=l;k<=r;k++){
				if(k==l){
					if(f[l+1][r][a[l]%(r-l-1)]>=a[l]){
						if(cmax(f[l][r][a[l]%(r-l)],a[l])){
							pos[l][r][a[l]%(r-l)]=l;
						}
					}
				}
				else if(k==r){
					if(f[l][r-1][a[r]%(r-l-1)]>=a[r])
						if(cmax(f[l][r][a[r]%(r-l)],a[r])){
							pos[l][r][a[r]%(r-l)]=r;
						}
				}
				else{
					int len1=k-l,len2=r-(k+1);
					for(int i=0;i<len1;i++)
						for(int j=0;j<len2;j++){
							int o=lcm(len1,len2);
							int t=solve(i,j,len1,len2,o);
							int up=min(f[l][k][i],f[k+1][r][j]);
							if(t<=up){
								t+=(up-t)/o*o;
								for(int p=0;p*o<=t;p++)
									if(cmax(f[l][r][(t-p*o)%(r-l)],t-p*o)){
										pos[l][r][(t-p*o)%(r-l)]=k;
									}
							}
						}
				}
			}
		}
	}
	if(f[1][n][0]==-1)puts("No");
	else{
		puts("Yes");
		dfs(1,n,0,0);
		for(int i=1;i<n;i++)cout<<b[i]<<' ';
		puts("");
	}
    #ifdef do_while_true
//		cerr<<'\n'<<"Time:"<<1.0*clock()/CLOCKS_PER_SEC*1000<<" ms"<<'\n';
	#endif
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 11
Accepted
time: 2ms
memory: 9128kb

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: 1ms
memory: 8688kb

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: 0ms
memory: 8328kb

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: 0ms
memory: 8212kb

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: 0ms
memory: 8944kb

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: 1ms
memory: 8232kb

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: 8860kb

input:

5
12 12 16 19 19

output:

Yes
3 3 5 8 

result:

ok The answer is correct.

Test #8:

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

input:

5
2 2 6 11 11

output:

Yes
2 0 3 8 

result:

ok The answer is correct.

Test #9:

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

input:

5
10 10 8 5 5

output:

Yes
5 3 1 2 

result:

ok The answer is correct.

Test #10:

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

input:

5
24 24 28 28 26

output:

Yes
6 6 9 7 

result:

ok The answer is correct.

Test #11:

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

input:

5
5 5 22 31 31

output:

Yes
2 1 10 19 

result:

ok The answer is correct.

Test #12:

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

input:

5
8 33 38 38 29

output:

Yes
2 11 16 9 

result:

ok The answer is correct.

Test #13:

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

input:

5
16 16 4 12 12

output:

Yes
13 1 1 9 

result:

ok The answer is correct.

Test #14:

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

input:

5
29 29 24 26 26

output:

Yes
11 6 6 8 

result:

ok The answer is correct.

Test #15:

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

input:

5
0 33 33 32 32

output:

Yes
0 13 10 12 

result:

ok The answer is correct.

Test #16:

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

input:

5
20 16 8 25 22

output:

No

result:

ok The answer is correct.

Test #17:

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

input:

5
0 2 3 0 2

output:

No

result:

ok The answer is correct.

Test #18:

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

input:

5
28 23 29 29 24

output:

No

result:

ok The answer is correct.

Test #19:

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

input:

5
0 1 0 4 2

output:

No

result:

ok The answer is correct.

Test #20:

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

input:

5
12 21 21 13 4

output:

No

result:

ok The answer is correct.

Test #21:

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

input:

5
9 22 25 23 12

output:

No

result:

ok The answer is correct.

Test #22:

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

input:

5
6 7 7 6 6

output:

Yes
2 3 1 3 

result:

ok The answer is correct.

Test #23:

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

input:

5
25 25 24 20 20

output:

Yes
8 7 5 5 

result:

ok The answer is correct.

Test #24:

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

input:

5
17 9 8 16 9

output:

No

result:

ok The answer is correct.

Test #25:

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

input:

5
20 5 34 34 23

output:

No

result:

ok The answer is correct.

Test #26:

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

input:

5
15 33 35 35 31

output:

No

result:

ok The answer is correct.

Test #27:

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

input:

5
21 22 23 1 18

output:

No

result:

ok The answer is correct.

Test #28:

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

input:

5
4 2 3 4 2

output:

No

result:

ok The answer is correct.

Test #29:

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

input:

5
16 25 8 19 7

output:

No

result:

ok The answer is correct.

Test #30:

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

input:

5
4 0 8 6 6

output:

No

result:

ok The answer is correct.

Test #31:

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

input:

2
2 3

output:

No

result:

ok The answer is correct.

Test #32:

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

input:

2
2 2

output:

Yes
2 

result:

ok The answer is correct.

Test #33:

score: -11
Wrong Answer
time: 1ms
memory: 6768kb

input:

1
0

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%