結果
問題 | No.1001 注文の多い順列 |
ユーザー | kotamanegi |
提出日時 | 2020-02-28 21:58:43 |
言語 | C++17(clang) (17.0.6 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 1,823 bytes |
コンパイル時間 | 1,747 ms |
コンパイル使用メモリ | 162,044 KB |
実行使用メモリ | 49,536 KB |
最終ジャッジ日時 | 2024-05-07 20:33:10 |
合計ジャッジ時間 | 3,480 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 3 ms
5,376 KB |
testcase_16 | AC | 3 ms
5,376 KB |
testcase_17 | AC | 3 ms
5,376 KB |
testcase_18 | AC | 43 ms
28,416 KB |
testcase_19 | AC | 42 ms
27,136 KB |
testcase_20 | AC | 28 ms
19,712 KB |
testcase_21 | AC | 25 ms
18,816 KB |
testcase_22 | AC | 52 ms
33,280 KB |
testcase_23 | AC | 52 ms
32,512 KB |
testcase_24 | AC | 7 ms
5,376 KB |
testcase_25 | AC | 49 ms
31,744 KB |
testcase_26 | AC | 85 ms
47,872 KB |
testcase_27 | AC | 86 ms
46,848 KB |
testcase_28 | AC | 77 ms
45,056 KB |
testcase_29 | AC | 16 ms
16,512 KB |
testcase_30 | AC | 18 ms
16,640 KB |
testcase_31 | AC | 19 ms
17,280 KB |
testcase_32 | AC | 13 ms
15,488 KB |
testcase_33 | AC | 80 ms
49,536 KB |
コンパイルメッセージ
main.cpp:2:18: warning: '#pragma comment linker' ignored [-Wignored-pragmas] 2 | #pragma comment (linker, "/STACK:526000000") | ^ 1 warning generated.
ソースコード
#define _CRT_SECURE_NO_WARNINGS #pragma comment (linker, "/STACK:526000000") #include "bits/stdc++.h" using namespace std; typedef string::const_iterator State; #define eps 1e-11L #define MAX_MOD 1000000007LL #define GYAKU 500000004LL #define MOD 998244353LL #define seg_size 262144 #define pb push_back #define mp make_pair typedef long long ll; #define REP(a,b) for(long long (a) = 0;(a) < (b);++(a)) #define ALL(x) (x).begin(),(x).end() unsigned long xor128() { static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL); unsigned long t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } void init() { iostream::sync_with_stdio(false); cout << fixed << setprecision(20); } #define int ll int dp[3001][3001] = {}; int limit_lower[3002]; int limit_higher[3002]; void solve() { int n; cin >> n; REP(i, n) { int a, b; cin >> a >> b; if (a == 0) { limit_lower[b]++; } else { limit_higher[b]++; } } for (int i = 0; i < 3001; ++i) { limit_higher[i + 1] += limit_higher[i]; limit_lower[i + 1] += limit_lower[i]; } dp[0][0] = 1; for (int i = 1; i <= n; ++i) { for (int q = 0; q <= limit_higher[i-1]; ++q) { if (dp[i-1][q] == 0) continue; //no take dp[i][q] += dp[i - 1][q]; dp[i][q] %= MAX_MOD; //take right dp[i][q + 1] += (dp[i - 1][q] * (limit_higher[i] - q)) % MAX_MOD; dp[i][q + 1] %= MAX_MOD; } for (int q = 0; q <= limit_higher[i]; ++q) { if (dp[i][q] == 0) continue; int now_have = i - q; now_have -= limit_lower[i - 1]; for (int j = 0; j < limit_lower[i] - limit_lower[i-1]; ++j) { dp[i][q] *= now_have; dp[i][q] %= MAX_MOD; now_have--; } dp[i][q] %= MAX_MOD; } } cout << dp[n][limit_higher[n]] << endl; } #undef int int main() { init(); solve(); }