結果
問題 |
No.2593 Reorder and Mod 120
|
ユーザー |
![]() |
提出日時 | 2025-05-10 00:47:14 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 927 bytes |
コンパイル時間 | 3,085 ms |
コンパイル使用メモリ | 281,032 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-05-10 00:47:19 |
合計ジャッジ時間 | 4,502 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 WA * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; string s; cin >> n >> s; set<int> st; if (n < 8) { vector<int> p(n); iota(p.begin(), p.end(), 0); do { int x = 0; rep(i, n) x = x * 10 + (s[p[i]] - '0'); st.insert(x % 120); } while (next_permutation(p.begin(), p.end())); } else { vector<int> cnt(10, 0); rep(i, n) cnt[s[i] - '0']++; rep(i, 10) rep(j, 10) rep(k, 10) { cnt[i]--, cnt[j]--, cnt[k]--; if (cnt[i] >= 0 && cnt[j] >= 0 && cnt[k] >= 0) { int x = i * 100 + j * 10 + k; st.insert(x); } cnt[i]++, cnt[j]++, cnt[k]++; } } cout << st.size() << '\n'; return 0; }