QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196493 | #6964. Werewolves | yiyiyi# | WA | 2ms | 3632kb | C++14 | 1.1kb | 2023-10-01 18:18:20 | 2023-10-01 18:18:20 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#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[33];
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);
}
}
signed 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("%lld ", (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: 3632kb
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