Submission #4330107


Source Code Expand

Copy
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> K;
	vector<vector<long long int>>dp(N + 2, vector<long long int>(2));
	vector<long long int>by(N + 2);
	for (long long int i = 0; i <= N+1; i++) {
		by[i] = power(2, max(0LL, i)*max(0LL, i - 1) / 2, MOD);
	}
	dp[0][1] = 1;
	for (long long int i = 1; i <= N + 1; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < i; k++) {
				//dp[i][j] += dp[k][j ^ 1] * power(2, max(0LL, i - k - 1 - K)*max(0LL, i - k - K) / 2, MOD);
				dp[i][j] += dp[k][j ^ 1] * by[max(0LL,i - k - K)];
				dp[i][j] %= MOD;
			}
		}
	}
	cout << (MOD + dp.back()[0] - dp.back()[1]) % MOD << endl;
	return 0;
}

Submission Info

Submission Time
Task E - Erasure
User olphe
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1471 Byte
Status
Exec Time 104 ms
Memory 512 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt
All 700 / 700 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt 1 ms 256 KB
01-02.txt 31 ms 384 KB
01-03.txt 8 ms 384 KB
01-04.txt 63 ms 512 KB
01-05.txt 62 ms 512 KB
01-06.txt 97 ms 512 KB
01-07.txt 104 ms 512 KB
01-08.txt 104 ms 512 KB
01-09.txt 104 ms 512 KB
01-10.txt 104 ms 512 KB
01-11.txt 104 ms 512 KB
sample-01.txt 1 ms 256 KB
sample-02.txt 1 ms 256 KB
sample-03.txt 104 ms 512 KB