QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#196490#6964. Werewolvesyiyiyi#WA 3ms3780kbC++141.0kb2023-10-01 18:15:572023-10-01 18:15:57

Judging History

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

  • [2023-10-01 18:15:57]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3780kb
  • [2023-10-01 18:15:57]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(int i=(s);i>=(t);i--)
using namespace std;
int ci(){
	int x; cin>>x; return x;
}

ll fac[1003];
void init_fac(int n){
	fac[0] = 1;
	rep(i,1,n) fac[i]=fac[i-1]*i;
}

int n, m;

int a[23];
int ans[(int)3e6+5], tot;

map<ll,int>mp;

void dfs(int cur, int c){
	if( cur==0 ){
		ll cnt = fac[n-1];
		a[n] = 0;
		int last = 0;
		rep(i,1,n-1){
			if( a[i]!=a[i+1] ){
				cnt /= fac[i-last];
				last = i;
			}
		}
		ans[++tot] = mp[cnt];
	//rep(i,1,n-1) printf("%lld ", a[i]); puts("");
	//	printf("line %d: cnt %d %d\n", __LINE__, cnt, mp[cnt]);
		mp[cnt] = (mp[cnt]+1)%m;
		return;
	}
	rev_rep(i,c,1){
		a[cur] = i;
		dfs(cur-1, i);
	}
}

int main(){
	int T = ci();
	while( T-- ){
		n = ci(), m = ci();
		init_fac(n);
		mp.clear();
		tot = 0;
		dfs(n-1,m);
		rep(p,0,n-1){
			rep(i,1,tot) printf("%d ", (ans[i]+p)%m+1); puts("");
		}
		//printf("line %d:\n", __LINE__);
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3780kb

input:

45
5 3
7 3
14 2
8 3
9 4
6 3
4 4
7 2
11 2
12 2
7 5
9 5
9 2
5 2
19 2
16 2
6 2
6 4
2 2
12 3
5 5
10 2
8 6
18 2
7 6
13 3
10 3
8 5
17 2
10 4
8 2
11 3
15 2
8 4
4 2
6 6
9 3
20 2
13 2
5 4
7 7
7 4
3 3
21 2
6 5

output:

1 1 2 1 1 2 3 2 3 1 2 2 3 3 3 
2 2 3 2 2 3 1 3 1 2 3 3 1 1 1 
3 3 1 3 3 1 2 1 2 3 1 1 2 2 2 
1 1 2 1 1 2 3 2 3 1 2 2 3 3 3 
2 2 3 2 2 3 1 3 1 2 3 3 1 1 1 
1 1 2 1 1 2 1 1 2 2 3 3 1 1 1 3 2 2 3 3 1 2 2 2 3 3 3 3 
2 2 3 2 2 3 2 2 3 3 1 1 2 2 2 1 3 3 1 1 2 3 3 3 1 1 1 1 
3 3 1 3 3 1 3 3 1 1 2 2 3 3 3 2...

result:

wrong answer Strategy not correct