QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#833290#1845. PermuteInvincibleWA 0ms3852kbC++232.1kb2024-12-26 16:47:342024-12-26 16:47:35

Judging History

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

  • [2024-12-26 16:47:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3852kb
  • [2024-12-26 16:47:34]
  • 提交

answer

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <ctime>
#include <random>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#define pii pair<int, int>
#define fi first
#define se second
#define MP make_pair
#define ep emplace
#define eb emplace_back
#define int long long
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
typedef double db;
typedef long double ldb;
typedef long long ll;
//typedef __int128 lll;
typedef unsigned long long ull;
typedef unsigned int ui;
using namespace std;
using namespace __gnu_pbds;
bool Mbe;

//char buf[1<<20],*p1,*p2;
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin), p1 == p2) ? 0 : *p1++)
int read() {
	int s = 0, f = 1;
	char c = getchar();
	while (c < '0' || c > '9') f ^= (c == '-'), c = getchar();
	while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
	return f ? s : -s;
}
template<typename T>void chkmax(T&x,const T&y){if(x<y)x=y;}
template<typename T>void chkmin(T&x,const T&y){if(x>y)x=y;}

bool Med;
const int N=1e5+5,mod=7;
int n,c[N],C[N],sum,p[N],id;
int fpow(int x,int k=mod-2){
	int res=1;
	for(;k;k>>=1){
		if(k&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}

signed main(){
	for(int T=read();T--;){
		sum=id=0;
		rep(i,0,8)C[i]=c[i]=read(),sum+=c[i];
		int lim=min(sum,8ll);
		while(id<lim){
			for(int i=0;i<10&&id<lim;i++){
				if(c[i]){
					c[i]--;
					p[++id]=i;
				}
			}
		}
		iota(p+1,p+id+1,1);
		int s=0;
		rep(i,0,9)s=(s*fpow(10,c[i])%mod+(fpow(10,c[i])+mod-1)%mod*fpow(9,mod-2)%mod*i%mod)%mod;
		s=s*fpow(10,id)%mod;
		bool flag=0;
		do{
			int tot=0;
			rep(i,1,id)tot=(tot*10%mod+p[i])%mod;
			if((s+tot)%mod==0){
				printf("%lld\n",10+id);
				rep(i,0,9)printf("%lld %lld\n",c[i],i);
				rep(i,1,id)printf("1 %lld\n",p[i]);
				flag=1;
				break;
			}
		}while(next_permutation(p+1,p+id+1));
		if(!flag)printf("-1\n");
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3852kb

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:

12
0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
1 2
1 1
13
0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
1 2
1 3
1 1
18
0 0
0 1
0 2
999999993 3
0 4
0 5
0 6
0 7
0 8
0 9
1 1
1 2
1 3
1 4
1 6
1 5
1 7
1 8

result:

wrong answer Participant output c[i]!=input c[i] in test 1