답안 #83454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83454 2018-11-08T01:09:27 Z tincamatei Tents (JOI18_tents) C++14
100 / 100
141 ms 36224 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 3000;
const int MOD = 1000000007;
int dp[1+MAX_N][1+MAX_N];

int main() {
#ifdef HOME
	FILE *fin = fopen("input.in", "r");
	FILE *fout = fopen("output.out", "w");
#else
	FILE *fin = stdin;
	FILE *fout = stdout;
#endif
	
	int n, m;
	fscanf(fin, "%d%d", &n, &m);
	
	for(int i = 0; i <= MAX_N; ++i)
		dp[0][i] = dp[i][0] = 1;
	
	for(int i = 1; i <= MAX_N; ++i)
		for(int j = 1; j <= MAX_N; ++j) {
			dp[i][j] = ((long long)dp[i - 1][j - 1] * j * 4) % MOD;
			if(i >= 2) dp[i][j] = ((long long)dp[i - 2][j - 1] * (i - 1) * j + dp[i][j]) % MOD;
			if(j >= 2) dp[i][j] = ((long long)dp[i - 1][j - 2] * j * (j - 1) / 2 + dp[i][j]) % MOD;
			dp[i][j] = ((long long)dp[i - 1][j] + dp[i][j]) % MOD;
		}
	
	fprintf(fout, "%d", (dp[n][m] - 1 + MOD) % MOD);

#ifdef HOME
	fclose(fin);
	fclose(fout);
#endif
	return 0;
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:19:8: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fscanf(fin, "%d%d", &n, &m);
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 35832 KB Output is correct
2 Correct 131 ms 35836 KB Output is correct
3 Correct 134 ms 35836 KB Output is correct
4 Correct 136 ms 35836 KB Output is correct
5 Correct 138 ms 35840 KB Output is correct
6 Correct 134 ms 36012 KB Output is correct
7 Correct 134 ms 36012 KB Output is correct
8 Correct 135 ms 36012 KB Output is correct
9 Correct 134 ms 36072 KB Output is correct
10 Correct 130 ms 36076 KB Output is correct
11 Correct 133 ms 36076 KB Output is correct
12 Correct 133 ms 36108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 35832 KB Output is correct
2 Correct 131 ms 35836 KB Output is correct
3 Correct 134 ms 35836 KB Output is correct
4 Correct 136 ms 35836 KB Output is correct
5 Correct 138 ms 35840 KB Output is correct
6 Correct 134 ms 36012 KB Output is correct
7 Correct 134 ms 36012 KB Output is correct
8 Correct 135 ms 36012 KB Output is correct
9 Correct 134 ms 36072 KB Output is correct
10 Correct 130 ms 36076 KB Output is correct
11 Correct 133 ms 36076 KB Output is correct
12 Correct 133 ms 36108 KB Output is correct
13 Correct 131 ms 36132 KB Output is correct
14 Correct 137 ms 36132 KB Output is correct
15 Correct 134 ms 36132 KB Output is correct
16 Correct 133 ms 36164 KB Output is correct
17 Correct 130 ms 36164 KB Output is correct
18 Correct 131 ms 36164 KB Output is correct
19 Correct 130 ms 36164 KB Output is correct
20 Correct 132 ms 36164 KB Output is correct
21 Correct 132 ms 36224 KB Output is correct
22 Correct 129 ms 36224 KB Output is correct
23 Correct 131 ms 36224 KB Output is correct
24 Correct 130 ms 36224 KB Output is correct
25 Correct 130 ms 36224 KB Output is correct
26 Correct 141 ms 36224 KB Output is correct
27 Correct 132 ms 36224 KB Output is correct