結果
問題 | No.2178 Payable Magic Items |
ユーザー | hari64 |
提出日時 | 2023-01-06 22:15:38 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,540 ms / 4,000 ms |
コード長 | 1,412 bytes |
コンパイル時間 | 2,234 ms |
コンパイル使用メモリ | 213,000 KB |
実行使用メモリ | 49,556 KB |
最終ジャッジ日時 | 2023-08-21 08:19:59 |
合計ジャッジ時間 | 22,659 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1,287 ms
33,868 KB |
testcase_04 | AC | 2 ms
4,384 KB |
testcase_05 | AC | 1,248 ms
33,856 KB |
testcase_06 | AC | 1,258 ms
33,892 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 1,291 ms
33,920 KB |
testcase_09 | AC | 191 ms
9,448 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 1,540 ms
49,464 KB |
testcase_12 | AC | 1,514 ms
49,552 KB |
testcase_13 | AC | 1,537 ms
49,548 KB |
testcase_14 | AC | 1,535 ms
49,484 KB |
testcase_15 | AC | 1,536 ms
49,528 KB |
testcase_16 | AC | 1,529 ms
49,556 KB |
testcase_17 | AC | 1,356 ms
38,904 KB |
testcase_18 | AC | 7 ms
4,376 KB |
testcase_19 | AC | 229 ms
13,092 KB |
testcase_20 | AC | 2 ms
4,376 KB |
testcase_21 | AC | 6 ms
4,376 KB |
testcase_22 | AC | 7 ms
4,376 KB |
testcase_23 | AC | 2 ms
4,376 KB |
testcase_24 | AC | 1,451 ms
44,860 KB |
testcase_25 | AC | 1,310 ms
35,932 KB |
testcase_26 | AC | 249 ms
14,716 KB |
ソースコード
#ifndef hari64 #include <bits/stdc++.h> // #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #define debug(...) #else #include "viewer.hpp" #define debug(...) viewer::_debug(__LINE__, #__VA_ARGS__, __VA_ARGS__) #endif // clang-format off using namespace std;constexpr int INF=1001001001;constexpr long long INFll=1001001001001001001; template<class T>bool chmax(T&a,const T&b){return a<b?a=b,1:0;} template<class T>bool chmin(T&a,const T&b){return a>b?a=b,1:0;} // clang-format on int main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; set<string> Ss; for (int i = 0; i < N; i++) { string S; cin >> S; Ss.insert(S); } int ans = 0; map<string, bool> memo; auto dfs = [&](const auto &f, string X) -> bool { if (memo.find(X) != memo.end()) return memo[X]; bool has_larger = false; for (int d = 0; d < K; d++) { if (X[d] != '4') { X[d]++; has_larger |= f(f, X); X[d]--; } } // debug(X, has_larger); if (Ss.find(X) != Ss.end()) { if (has_larger) { ans++; } has_larger = true; } return memo[X] = has_larger; }; dfs(dfs, string(K, '0')); cout << ans << endl; return 0; }