結果
問題 | No.941 商とあまり |
ユーザー | QCFium |
提出日時 | 2019-11-04 09:21:00 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 352 ms / 2,000 ms |
コード長 | 2,340 bytes |
コンパイル時間 | 2,573 ms |
コンパイル使用メモリ | 197,320 KB |
実行使用メモリ | 6,772 KB |
最終ジャッジ日時 | 2024-09-14 23:38:20 |
合計ジャッジ時間 | 12,138 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
5,248 KB |
testcase_01 | AC | 3 ms
5,376 KB |
testcase_02 | AC | 3 ms
5,376 KB |
testcase_03 | AC | 3 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 3 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 10 ms
5,376 KB |
testcase_08 | AC | 10 ms
5,376 KB |
testcase_09 | AC | 9 ms
5,376 KB |
testcase_10 | AC | 14 ms
5,376 KB |
testcase_11 | AC | 9 ms
5,376 KB |
testcase_12 | AC | 6 ms
5,376 KB |
testcase_13 | AC | 58 ms
5,708 KB |
testcase_14 | AC | 8 ms
5,376 KB |
testcase_15 | AC | 14 ms
5,376 KB |
testcase_16 | AC | 17 ms
5,376 KB |
testcase_17 | AC | 130 ms
6,160 KB |
testcase_18 | AC | 231 ms
6,772 KB |
testcase_19 | AC | 352 ms
6,712 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 3 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 14 ms
5,376 KB |
testcase_27 | AC | 12 ms
5,376 KB |
testcase_28 | AC | 8 ms
5,376 KB |
testcase_29 | AC | 24 ms
5,376 KB |
testcase_30 | AC | 25 ms
5,376 KB |
testcase_31 | AC | 8 ms
5,376 KB |
testcase_32 | AC | 7 ms
5,376 KB |
testcase_33 | AC | 3 ms
5,376 KB |
testcase_34 | AC | 231 ms
6,768 KB |
testcase_35 | AC | 167 ms
6,332 KB |
testcase_36 | AC | 10 ms
5,376 KB |
testcase_37 | AC | 11 ms
5,376 KB |
testcase_38 | AC | 10 ms
5,376 KB |
testcase_39 | AC | 15 ms
5,376 KB |
testcase_40 | AC | 3 ms
5,376 KB |
testcase_41 | AC | 3 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 9 ms
5,376 KB |
testcase_44 | AC | 9 ms
5,376 KB |
testcase_45 | AC | 65 ms
5,376 KB |
testcase_46 | AC | 43 ms
5,376 KB |
testcase_47 | AC | 6 ms
5,376 KB |
testcase_48 | AC | 3 ms
5,376 KB |
testcase_49 | AC | 10 ms
5,376 KB |
testcase_50 | AC | 10 ms
5,376 KB |
testcase_51 | AC | 10 ms
5,376 KB |
testcase_52 | AC | 10 ms
5,376 KB |
testcase_53 | AC | 8 ms
5,376 KB |
testcase_54 | AC | 65 ms
5,376 KB |
testcase_55 | AC | 60 ms
5,376 KB |
testcase_56 | AC | 62 ms
5,376 KB |
testcase_57 | AC | 269 ms
5,836 KB |
testcase_58 | AC | 217 ms
5,568 KB |
testcase_59 | AC | 10 ms
5,376 KB |
testcase_60 | AC | 10 ms
5,376 KB |
testcase_61 | AC | 6 ms
5,376 KB |
testcase_62 | AC | 21 ms
5,376 KB |
testcase_63 | AC | 12 ms
5,376 KB |
testcase_64 | AC | 22 ms
5,376 KB |
testcase_65 | AC | 25 ms
5,376 KB |
testcase_66 | AC | 16 ms
5,376 KB |
testcase_67 | AC | 35 ms
5,376 KB |
testcase_68 | AC | 12 ms
5,376 KB |
testcase_69 | AC | 40 ms
5,376 KB |
testcase_70 | AC | 47 ms
5,376 KB |
testcase_71 | AC | 22 ms
5,376 KB |
testcase_72 | AC | 22 ms
5,376 KB |
testcase_73 | AC | 49 ms
5,376 KB |
testcase_74 | AC | 55 ms
5,376 KB |
testcase_75 | AC | 46 ms
5,376 KB |
testcase_76 | AC | 58 ms
5,376 KB |
testcase_77 | AC | 33 ms
5,376 KB |
testcase_78 | AC | 84 ms
5,376 KB |
testcase_79 | AC | 65 ms
5,376 KB |
testcase_80 | AC | 68 ms
5,376 KB |
testcase_81 | AC | 93 ms
5,376 KB |
testcase_82 | AC | 68 ms
5,376 KB |
testcase_83 | AC | 36 ms
5,376 KB |
testcase_84 | AC | 66 ms
5,376 KB |
testcase_85 | AC | 91 ms
5,376 KB |
testcase_86 | AC | 80 ms
5,376 KB |
testcase_87 | AC | 60 ms
5,376 KB |
testcase_88 | AC | 80 ms
5,376 KB |
testcase_89 | AC | 146 ms
5,484 KB |
testcase_90 | AC | 112 ms
5,376 KB |
testcase_91 | AC | 169 ms
5,624 KB |
testcase_92 | AC | 139 ms
5,468 KB |
testcase_93 | AC | 102 ms
5,376 KB |
testcase_94 | AC | 64 ms
5,376 KB |
testcase_95 | AC | 117 ms
5,376 KB |
testcase_96 | AC | 69 ms
5,376 KB |
testcase_97 | AC | 84 ms
5,376 KB |
testcase_98 | AC | 2 ms
5,376 KB |
testcase_99 | AC | 75 ms
5,376 KB |
testcase_100 | AC | 106 ms
5,376 KB |
testcase_101 | AC | 3 ms
5,376 KB |
testcase_102 | AC | 3 ms
5,376 KB |
testcase_103 | AC | 154 ms
5,564 KB |
testcase_104 | AC | 2 ms
5,376 KB |
testcase_105 | AC | 2 ms
5,376 KB |
testcase_106 | AC | 2 ms
5,376 KB |
testcase_107 | AC | 2 ms
5,376 KB |
testcase_108 | AC | 2 ms
5,376 KB |
testcase_109 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } std::string solve(int n, int x, const std::vector<int> &a_) { auto a = a_; if (n == 1) { std::string s(x, '0'); if (a[0] <= x) s[a[0] - 1] = '1'; return s; } std::sort(a.begin(), a.end()); int64_t prod = 1; for (int i = 0; i < n; i++) { prod *= a[i] + 1; if (prod > x + 1) return std::string(x, '0'); } std::map<int, int> nums; for (auto i : a) nums[i]++; std::vector<std::pair<int, int> > all; for (auto i : nums) all.push_back(i); std::map<std::vector<int>, std::vector<bool> > dp; int m = nums.size(); for (int i = 0; i < m; i++) { std::vector<int> num(all.size()); num[i] = 1; int size = x + 1; for (int j = 0; j < m; j++) for (int k = 0; k < all[j].second - num[j]; k++) size /= all[j].first; std::vector<bool> val(size); assert(all[i].first < size); val[all[i].first] = true; dp[num] = val; } for (auto &i : dp) { for (int j = 0; j < m; j++) { if (i.first[j] == all[j].second) continue; auto new_num = i.first; new_num[j]++; int new_size = x + 1; for (int k = 0; k < m; k++) for (int l = 0; l < all[k].second - new_num[k]; l++) new_size /= all[k].first; std::vector<bool> new_val(new_size); for (int k = 1; k < (int) i.second.size(); k++) { if (!i.second[k]) continue; int64_t target = (int64_t) (k + 1) * (all[j].first + 1) - 1; if (target < new_size) new_val[target] = true; } for (int k = 0; k < new_size - all[j].first; k++) if (new_val[k]) new_val[k + all[j].first] = true; auto &res = dp[new_num]; if (!res.size()) res = new_val; else for (int k = 0; k < new_size; k++) if (new_val[k]) res[k] = true; } } std::vector<int> final(m); for (int i = 0; i < m; i++) final[i] = all[i].second; assert(dp.count(final)); auto res = dp[final]; assert((int) res.size() == x + 1); std::string ans; for (int i = 1; i <= x; i++) ans.push_back(res[i] ? '1' : '0'); return ans; } int main() { int n = ri(), x = ri(); assert(1 <= n && n <= 100); assert(1 <= x && x <= 500000); std::vector<int> a(n); for (int i = 0; i < n; i++) a[i] = ri(), assert(1 <= a[i] && a[i] <= x); clock_t r0 = clock(); std::cout << solve(n, x, a) << std::endl; clock_t r1 = clock(); std::cerr << (double)(r1 - r0) * 1000 / CLOCKS_PER_SEC << "ms" << std::endl; return 0; }