Submission #1815115
Source Code Expand
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb(a) push_back(a)
const int mod = 924844033, N = 2010;
int n, k, f[N][N][4], F[N][N], fac[N], g[N];
int main() {
scanf("%d%d",&n,&k);
f[0][0][3] = 1;
rep(i,1,n / k + 1) rep(j,0,i) Rep(s,4) Rep(s1,4) {
if ((s & 1) && (s1 & 2)) continue;
if ((s & 2) && (s1 & 1)) continue;
(f[i][j + (s1 & 1) + (s1 >> 1 & 1)][s1] += f[i - 1][j][s]) %= mod;
}
fac[0] = 1; rep(i,1,n) fac[i] = 1LL * fac[i - 1] * i % mod;
rep(i,0,n / k + 1) rep(j,0,i) {
F[i][j] = 0;
Rep(s,4) (F[i][j] += f[i][j][s]) %= mod;
}
g[0] = 1;
Rep(r,k) {
int c = (n - 1 - r) / k + 1;
dep(i,n,0) {
int s = 0;
rep(j,0,min(i, c)) if (F[c][j])
s = (s + 1LL * F[c][j] * g[i - j]) % mod;
g[i] = s;
}
}
int cof = 1, ans = 0;
rep(i,0,n) {
ans = (ans + 1LL * cof * fac[n - i] % mod * g[i]) % mod;
cof = -cof;
}
if (ans < 0) ans += mod;
printf("%d\n",ans);
return 0;
}
Submission Info
Submission Time
2017-11-28 23:41:17+0900
Task
D - ~K Perm Counting
User
WuHongxun
Language
C++14 (GCC 5.4.1)
Score
900
Code Size
1318 Byte
Status
AC
Exec Time
125 ms
Memory
78080 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:21:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&k);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
900 / 900
Status
Set Name
Test Cases
Sample
example0, example1, example2, example3, example4
All
example0, example1, example2, example3, example4, handmade0, handmade1, handmade2, handmade3, handmade4, handmade5, handmade6, maxrand0, maxrand1, maxrand2, maxrand3, maxrand4, rand0, rand1, rand2, rand3, rand4, small0, small1, small2, supersmall0, supersmall1, supersmall2
Case Name
Status
Exec Time
Memory
example0
AC
2 ms
2304 KB
example1
AC
1 ms
2304 KB
example2
AC
2 ms
2304 KB
example3
AC
2 ms
2304 KB
example4
AC
2 ms
2304 KB
handmade0
AC
2 ms
2304 KB
handmade1
AC
125 ms
78080 KB
handmade2
AC
17 ms
2304 KB
handmade3
AC
112 ms
75136 KB
handmade4
AC
15 ms
2304 KB
handmade5
AC
20 ms
4480 KB
handmade6
AC
20 ms
4480 KB
maxrand0
AC
17 ms
2304 KB
maxrand1
AC
16 ms
2304 KB
maxrand2
AC
16 ms
2304 KB
maxrand3
AC
19 ms
6784 KB
maxrand4
AC
16 ms
2304 KB
rand0
AC
17 ms
2304 KB
rand1
AC
3 ms
2304 KB
rand2
AC
3 ms
2304 KB
rand3
AC
1 ms
2304 KB
rand4
AC
15 ms
2304 KB
small0
AC
2 ms
2304 KB
small1
AC
2 ms
2304 KB
small2
AC
2 ms
2304 KB
supersmall0
AC
2 ms
2304 KB
supersmall1
AC
2 ms
2304 KB
supersmall2
AC
2 ms
2304 KB