Submission #1814722
Source Code Expand
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
typedef long long ll;
//////////////////////
int const N = 2e3 + 41;
int const MOD = 924844033;
int n, k, q;
int d[2][N][2][2];
int ans;
void add(int &a, int b){
a += b;
if(a >= MOD) a -= MOD;
}
int mul(int a, int b){
return (ll) a * b % MOD;
}
void clear(int id){
memset(d[id], 0, sizeof(d[id]));
}
void solvechain(int m){
fi(0, m){
int p0 = (q&1);
int p1 = (1 ^ p0);
clear(p1);
fj(0, N){
for(int f0=0;f0<2;++f0){
for(int f1=0;f1<2;++f1){
int v = d[p0][j][f1][f0];
if(v){
//1
add(d[p1][j][0][0], v);
//2
add(d[p1][j+1][1][1], v);
//3
if(j){
int v1 = j - f0;
add(d[p1][j][1][0], mul(v, v1));
}
//4
if(j){
int v1 = j - f1;
add(d[p1][j][0][1], mul(v, v1));
}
//5
if(j){
int v1 = j - f0;
int v2 = j - f1;
add(d[p1][j-1][0][0], mul(v, mul(v1, v2)));
}
}
}
}
}
++q;
}
int pq = (q&1);
fi(0, N){
int s = 0;
for(int f0=0;f0<2;++f0){
for(int f1=0;f1<2;++f1){
add(s, d[pq][i][f0][f1]);
d[pq][i][f0][f1] = 0;
}
}
d[pq][i][0][0] = s;
}
}
void solve(){
d[0][0][0][0] = 1;
fi(0, k){
solvechain((n - i + k - 1) / k);
}
ans = d[(q&1)][0][0][0];
}
int main(){
#ifdef _DEBUG
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
scanf("%d %d",&n,&k);
solve();
printf("%d\n",ans);
return 0;
}
Submission Info
Submission Time
2017-11-28 20:43:16+0900
Task
D - ~K Perm Counting
User
Filyan
Language
C++14 (GCC 5.4.1)
Score
900
Code Size
1699 Byte
Status
AC
Exec Time
163 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:95:22: 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
1 ms
256 KB
example1
AC
1 ms
256 KB
example2
AC
1 ms
256 KB
example3
AC
1 ms
256 KB
example4
AC
11 ms
256 KB
handmade0
AC
1 ms
256 KB
handmade1
AC
163 ms
256 KB
handmade2
AC
62 ms
256 KB
handmade3
AC
146 ms
256 KB
handmade4
AC
54 ms
256 KB
handmade5
AC
160 ms
256 KB
handmade6
AC
161 ms
256 KB
maxrand0
AC
63 ms
256 KB
maxrand1
AC
106 ms
256 KB
maxrand2
AC
113 ms
256 KB
maxrand3
AC
148 ms
256 KB
maxrand4
AC
57 ms
256 KB
rand0
AC
137 ms
256 KB
rand1
AC
16 ms
256 KB
rand2
AC
16 ms
256 KB
rand3
AC
3 ms
256 KB
rand4
AC
58 ms
256 KB
small0
AC
7 ms
256 KB
small1
AC
4 ms
256 KB
small2
AC
6 ms
256 KB
supersmall0
AC
1 ms
256 KB
supersmall1
AC
1 ms
256 KB
supersmall2
AC
1 ms
256 KB