QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#196553#6964. WerewolvesyiyiyiWA 2ms3792kbC++14848b2023-10-01 19:02:372023-10-01 19:02:37

Judging History

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

  • [2023-10-01 19:02:37]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3792kb
  • [2023-10-01 19:02:37]
  • 提交

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;
}

int n, m;

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

void dfs(int cur, int c){
	if( cur==0 ){
		int cnt = 0, sum = 0;
		int mx = 0;
		rep(i,1,m) mx = max(mx, a[i]);
		rep(i,1,m) if( a[i]==mx ) sum+=i-1, cnt++;
		ans[++tot] = sum%m;
		//printf("line %d: mx %d sum %d %d\n", __LINE__, mx, sum, cnt);
		return;
	}
	rev_rep(i,c,1){
		a[i]++;
		dfs(cur-1, i);
		a[i]--;
	}
}

signed main(){
	int T = ci();
	while( T-- ){
		n = ci(), m = ci();
		//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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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:

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

result:

wrong answer Strategy not correct