結果
問題 |
No.3001 ヘビ文字列
|
ユーザー |
|
提出日時 | 2025-01-02 01:53:06 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,265 bytes |
コンパイル時間 | 4,108 ms |
コンパイル使用メモリ | 348,080 KB |
実行使用メモリ | 22,056 KB |
最終ジャッジ日時 | 2025-01-02 01:53:40 |
合計ジャッジ時間 | 30,635 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 61 |
ソースコード
#include <bits/extc++.h> int main() { using namespace std; string S; cin >> S; const unsigned N(size(S)); string ans{}; auto prefix_min{numeric_limits<unsigned>::max()}; unsigned repeat{}; for (const auto p : [](unsigned N) { const auto M{N}; vector<unsigned> result{1}; for (unsigned p{2}; p * p <= N; ++p) if (N % p == 0) { result.emplace_back(p); while (N % p == 0) N /= p; } if (N > 1 && N < M) result.emplace_back(N); return result; }(N) | views::reverse) { vector<array<unsigned, 26>> counter(p); for (unsigned i{}; const auto c : S) ++counter[i++ % p][c - 65]; auto modify_count{N}; string tmp{}; for (const auto &x : counter) { const auto &it{ranges::max_element(x)}; tmp += static_cast<char>(ranges::distance(begin(x), it) + 65); modify_count -= *it; } if (modify_count < prefix_min) { prefix_min = modify_count; ans = tmp; repeat = N / p; } } for (unsigned i{}; i < repeat; ++i) cout << ans; cout << endl; return 0; }