QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#75768#5460. Sum of Numberschenshi#WA 963ms4312kbC++783b2023-02-06 10:11:462023-02-06 10:11: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-02-06 10:11:49]
  • 评测
  • 测评结果:WA
  • 用时:963ms
  • 内存:4312kb
  • [2023-02-06 10:11:46]
  • 提交

answer

#include<cstdio>
#include<iostream>
using namespace std;
const int o=2e5+10;
int T,n,K,a[9],len,ans[o],v[o];char str[o];
void dfs(int nw,int s){
	if(nw==K){
		a[K]=n-s;s=0;
		for(int i=1;i<=n;++i) v[i]=0;
		for(int i=1;i<=K;s+=a[i++]) for(int j=1;j<=a[i];++j) v[a[i]-j+1]+=str[j+s]-48;
		for(int i=n;i;--i)
			if(v[i]>ans[i]) break;
			else if(v[i]<ans[i]){
				for(int j=1;j<=i;++j) ans[j]=v[j];
				break;
			}
		return;
	}
	for(int i=max(n-s-(K-nw)*len,1);i<=len&&s+i+K-nw<=n;++i) a[nw]=i,dfs(nw+1,s+i);
}
int main(){
	for(scanf("%d",&T);T--;putchar('\n')){
		scanf("%d%d%s",&n,&K,str+1);++K;
		for(int i=1;i<=n;++i) ans[i]=str[n-i+1]-48;
		len=(n+K-1)/K+1;dfs(1,0);
		for(int i=n,flg=0;i;--i) if(ans[i]||flg) printf("%d",ans[i]),flg=1;
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3572kb

input:

2
8 1
45455151
2 1
42

output:

9696
6

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 963ms
memory: 4312kb

input:

10
1301 6
56328399613959594774559774218276494124991536454496431869449134772679831477279356599352619469813771742358572734317965823527349354276551857226632977613336815474383422853946661428822284645652423563864641261338984158269966469425994769486371736593879954275146732544891889693921182364554588732946...

output:

253329244033414141382644224036452631343633373333434034353436353829444237333442443241264332383235423624372037393534285048263035333934343137223524314934503142423937323241373031294229403832222933312946222735223729452735333943263538262941363734383842274628373437264331392430403840313825332431403434354027...

result:

wrong answer 1st lines differ - expected: '286183755510664079479706773787...6909797866802717925250679901255', found: '253329244033414141382644224036...5262932275047342346362728293235'