Submission #1865319


Source Code Expand

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef double db;
const int N = 2005, mod = 924844033;
int n, m;
ll fac[N], f[N][N][2][2], ans, res;
int main()
{
	scanf ("%d%d", &n, &m);
	fac[0] = 1;
	Rep(i, 1, n) fac[i] = fac[i - 1] * i % mod;
	int i = 1;
	f[0][0][0][0] = 1;
	Rep(r, 1, n) {
		bool f1, f2;
		if (r > 1) {
			if (i + m > n) i = i % m + 1, f1 = 0;
			else i = i + m, f1 = 1;
		} else f1 = 0;
		// cout << i<<endl;
		f2 = (i + m <= n);
		Rep(j, 0, r) Rep(p1, 0, 1) Rep(p2, 0, 1) {
			Rep(q1, 0, f1) Rep(q2, 0, f2) if (!(p1 & q1) && !(q1 & q2)) {
				(f[r][j + (q1 | q2)][p2][q2] += f[r - 1][j][p1][p2]) %= mod;
			}
		}
	}
	int k = 1;
	Rep(i, 0, n) {
		res = 0;
		Rep(p1, 0, 1) Rep(p2, 0, 1) (res += f[n][i][p1][p2]) %= mod;
		(ans += res * fac[n - i] * k) %= mod;
		k *= -1;
	}
	printf("%lld\n", (ans + mod) % mod);

	return 0;
}

Submission Info

Submission Time
Task D - ~K Perm Counting
User hzt1
Language C++14 (GCC 5.4.1)
Score 900
Code Size 1285 Byte
Status AC
Exec Time 112 ms
Memory 123776 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:25:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d%d", &n, &m);
                        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 900 / 900
Status
AC × 5
AC × 28
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 12 ms 27008 KB
handmade0 AC 1 ms 256 KB
handmade1 AC 112 ms 123776 KB
handmade2 AC 70 ms 123776 KB
handmade3 AC 101 ms 117120 KB
handmade4 AC 64 ms 115072 KB
handmade5 AC 110 ms 123776 KB
handmade6 AC 110 ms 123776 KB
maxrand0 AC 70 ms 119168 KB
maxrand1 AC 84 ms 119168 KB
maxrand2 AC 88 ms 123264 KB
maxrand3 AC 103 ms 119168 KB
maxrand4 AC 67 ms 119168 KB
rand0 AC 98 ms 123264 KB
rand1 AC 16 ms 37248 KB
rand2 AC 18 ms 43392 KB
rand3 AC 3 ms 4480 KB
rand4 AC 63 ms 110976 KB
small0 AC 8 ms 18816 KB
small1 AC 5 ms 10624 KB
small2 AC 6 ms 14720 KB
supersmall0 AC 1 ms 256 KB
supersmall1 AC 1 ms 256 KB
supersmall2 AC 1 ms 256 KB