結果
問題 |
No.2593 Reorder and Mod 120
|
ユーザー |
|
提出日時 | 2023-12-22 00:16:11 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 737 bytes |
コンパイル時間 | 862 ms |
コンパイル使用メモリ | 87,992 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-27 11:15:24 |
合計ジャッジ時間 | 3,983 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 RE * 16 |
ソースコード
#include <iostream> #include <numeric> #include <algorithm> using namespace std; constexpr int Z = 40; void dfs(int cnt[10], int n, int a, bool f[]) { if (n == 0) { f[a%Z] = true; return; } for (int i = 0; i < 10; i++) { if (cnt[i] > 0) { cnt[i]--; dfs(cnt, n - 1, a * 10 + i, f); cnt[i]++; } } } int main() { int n; cin >> n; int cnt[10] = {0}; for (int i = 0; i < n; i++) { char c; cin >> c; cnt[c-'0']++; } for (int i = 0; i < n; i++) { cnt[i] = min(cnt[i], 3); } bool f[Z] = {false}; dfs(cnt, min(3, n), 0, f); cout << accumulate(f, f + Z, 0) << endl; return 0; }