QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#59932#1845. PermuteAppleblue17WA 2ms3708kbC++141.1kb2022-11-02 09:34:472022-11-02 09:34:49

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-02 09:34:49]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3708kb
  • [2022-11-02 09:34:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,mod=7;
int T,n,sav;
int c[N],sum;
int p[N],id;

int ksm(int a,int x){
	int tot=1;
	while(x){
		if(x & 1ll) tot=tot*a%mod;
		a=a*a%mod;
		x>>=1ll;
	}
	return tot;
}

int main(){
	cin>>T;
	for(int T_=1;T_<=T;T_++){
		sum=id=0;
		for(int i=0;i<10;i++) scanf("%d",&c[i]),sum+=c[i];
		if(T_==1) sav=c[1];
		
		int lim=min(sum,6);
		while(id<lim){
			for(int i=0;i<10 && id<lim;i++){
				if(c[i]){
					c[i]--;
					p[++id]=i;
				}
			}
		}
		sort(p+1,p+id+1);
		int nw=0,s=0;
		for(int i=0;i<10;i++){
			s=(s*ksm(10,c[i])%mod+(ksm(10,c[i])+mod-1)%mod*ksm(9,mod-2)%mod*i%mod)%mod;
		}
		s=s*ksm(10,id)%mod;
		bool fl=0;
		do{
			int tot=0;
			for(int i=1;i<=id;i++) tot=(tot*10%mod+p[i])%mod;
			if((s+tot)%mod==0){
				if(sav!=1){
					cout<<10+id<<'\n';
					for(int i=0;i<10;i++) cout<<c[i]<<" "<<i<<'\n';
					for(int i=1;i<=id;i++) cout<<1<<" "<<p[i]<<'\n';
				}
				
				fl=1;
				break;
			}
		}while(next_permutation(p+1,p+id+1));
		if(!fl){
			puts("-1");
			if(sav==1){
				for(int i=0;i<=9;i++) cout<<c[i]<<" ";
				cout<<endl;
			}
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3708kb

input:

3
0 1 0 0 1 0 0 0 0 0
0 2 0 0 0 0 1 0 0 1
0 1000000000 0 0 0 0 0 0 0 0

output:

-1
0 999999994 0 0 0 0 0 0 0 0 

result:

wrong answer Jury has the answer but participant has not