Submission #2212934


Source Code Expand

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<random>
#include<map>
using namespace std;
#define int long long
const long long mod = 1000000007;

int kaijo[200005];
int ikaijo[200005];
int modp(int x, int n, int md) {
	if (n == 0)return 1;
	int res = modp(x*x%md, n / 2, md);
	if (n & 1)res = res*x%mod;
	return res;
}

signed main() {
	int h, w, a, b; cin >> h >> w >> a >> b;
	kaijo[0] = 1;
	for (int i = 1; i <= h+w; i++)kaijo[i] = (kaijo[i - 1] * i)%mod;
	for (int j = 0; j <= h + w; j++) {
		ikaijo[j] = modp(kaijo[j], mod - 2, mod);
	}
	int ans = 0;
	for (int i =  b + 1; i <= w; i++) {
		int x = h - a, y = i, X = a, Y = w-i+1;
		int cm = (kaijo[x + y - 2] * ikaijo[x - 1] %mod* ikaijo[y - 1])%mod;
		int CM = (kaijo[X + Y - 2] * ikaijo[X - 1]%mod * ikaijo[Y - 1])%mod;
		ans += ((cm * CM) % mod);
		ans %= mod;
			}
	cout << ans << endl;
}

Submission Info

Submission Time
Task D - Iroha and a Grid
User Rho17
Language C++14 (GCC 5.4.1)
Score 400
Code Size 974 Byte
Status AC
Exec Time 91 ms
Memory 3328 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 26
Set Name Test Cases
Sample subtask0_01.txt, subtask0_02.txt, subtask0_03.txt, subtask0_04.txt
All subtask0_01.txt, subtask0_02.txt, subtask0_03.txt, subtask0_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_max.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_max.txt
Case Name Status Exec Time Memory
subtask0_01.txt AC 1 ms 256 KB
subtask0_02.txt AC 1 ms 256 KB
subtask0_03.txt AC 90 ms 3328 KB
subtask0_04.txt AC 90 ms 3328 KB
subtask1_01.txt AC 1 ms 256 KB
subtask1_02.txt AC 1 ms 256 KB
subtask1_03.txt AC 1 ms 256 KB
subtask1_04.txt AC 1 ms 256 KB
subtask1_05.txt AC 1 ms 256 KB
subtask1_06.txt AC 1 ms 256 KB
subtask1_07.txt AC 1 ms 256 KB
subtask1_08.txt AC 1 ms 256 KB
subtask1_09.txt AC 1 ms 256 KB
subtask1_10.txt AC 1 ms 256 KB
subtask1_max.txt AC 1 ms 256 KB
subtask2_01.txt AC 8 ms 512 KB
subtask2_02.txt AC 9 ms 512 KB
subtask2_03.txt AC 6 ms 384 KB
subtask2_04.txt AC 9 ms 512 KB
subtask2_05.txt AC 7 ms 512 KB
subtask2_06.txt AC 90 ms 3328 KB
subtask2_07.txt AC 90 ms 3328 KB
subtask2_08.txt AC 90 ms 3328 KB
subtask2_09.txt AC 90 ms 3328 KB
subtask2_10.txt AC 91 ms 3328 KB
subtask2_max.txt AC 10 ms 512 KB