結果
問題 | No.3001 ヘビ文字列 |
ユーザー | Flkanjin |
提出日時 | 2025-01-01 12:37:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,115 bytes |
コンパイル時間 | 3,050 ms |
コンパイル使用メモリ | 200,768 KB |
実行使用メモリ | 144,400 KB |
最終ジャッジ日時 | 2025-01-01 12:38:12 |
合計ジャッジ時間 | 48,874 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | WA | - |
testcase_03 | AC | 3 ms
6,816 KB |
testcase_04 | AC | 3 ms
6,816 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 413 ms
144,064 KB |
testcase_16 | AC | 416 ms
143,072 KB |
testcase_17 | AC | 407 ms
142,968 KB |
testcase_18 | AC | 480 ms
143,820 KB |
testcase_19 | AC | 453 ms
143,492 KB |
testcase_20 | AC | 437 ms
142,976 KB |
testcase_21 | AC | 450 ms
142,876 KB |
testcase_22 | AC | 465 ms
143,616 KB |
testcase_23 | AC | 420 ms
142,836 KB |
testcase_24 | AC | 482 ms
143,436 KB |
testcase_25 | AC | 61 ms
7,248 KB |
testcase_26 | AC | 63 ms
7,544 KB |
testcase_27 | AC | 64 ms
7,932 KB |
testcase_28 | AC | 63 ms
7,252 KB |
testcase_29 | AC | 63 ms
7,868 KB |
testcase_30 | AC | 64 ms
7,572 KB |
testcase_31 | AC | 62 ms
8,668 KB |
testcase_32 | AC | 63 ms
8,080 KB |
testcase_33 | AC | 64 ms
7,372 KB |
testcase_34 | AC | 63 ms
7,376 KB |
testcase_35 | AC | 55 ms
7,808 KB |
testcase_36 | AC | 56 ms
8,320 KB |
testcase_37 | AC | 76 ms
7,248 KB |
testcase_38 | AC | 54 ms
7,672 KB |
testcase_39 | AC | 54 ms
7,488 KB |
testcase_40 | AC | 54 ms
8,184 KB |
testcase_41 | AC | 54 ms
8,644 KB |
testcase_42 | AC | 55 ms
8,068 KB |
testcase_43 | AC | 58 ms
8,904 KB |
testcase_44 | AC | 54 ms
7,768 KB |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | AC | 653 ms
139,480 KB |
testcase_48 | AC | 660 ms
139,444 KB |
testcase_49 | AC | 679 ms
139,588 KB |
testcase_50 | AC | 679 ms
139,456 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | AC | 659 ms
143,132 KB |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | AC | 404 ms
139,020 KB |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | AC | 626 ms
142,584 KB |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | AC | 2 ms
6,820 KB |
testcase_86 | AC | 2 ms
6,820 KB |
ソースコード
#include <algorithm> #include <array> #include <bit> #include <bitset> #include <cassert> #include <cctype> #include <chrono> #include <climits> #include <clocale> #include <cmath> #include <complex> #include <concepts> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numbers> #include <numeric> #include <queue> #include <random> #include <ranges> #include <regex> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> constexpr int MOD{1'000'000'007}; constexpr int MOD2{998'244'353}; constexpr int INF{1'000'000'000}; //1e9 constexpr int NIL{-1}; constexpr long long LINF{1'000'000'000'000'000'000}; // 1e18 constexpr long double EPS{1E-10L}; using namespace std::literals; namespace ranges = std::ranges; namespace views = ranges::views; template<class T, class S> bool chmax(T &a, const S &b){ if(a < b){a = b; return true;} return false; } template<class T, class S> bool chmin(T &a, const S &b){ if(b < a){a = b; return true;} return false; } template<class T> bool inside(T x, T lx, T rx){ //semi-open return (ranges::clamp(x, lx, rx-1) == x); } template<class T> bool inside(T x, T y, T lx, T rx, T ly, T ry){ return inside(x, lx, rx) && inside(y, ly, ry); } template<class T, class S> std::istream &operator>>(std::istream &is, std::pair<T, S> &p){ return is >> p.first >> p.second; } template<class T, class S> std::ostream &operator<<(std::ostream &os, const std::pair<T, S> &p){ return os << p.first << " " << p.second; } template<class T> std::istream &operator>>(std::istream &is, std::vector<T> &v){ {for(auto &e: v) is >> e;} return is; } template<class Container> void print_container(const Container &c, std::string sep = " "s, std::string end = "\n"s){ for(int i{int(std::size(c))}; auto e: c) std::cout << e << (--i ? sep : end); } std::string yesno(bool x){return x ? "Yes"s : "No"s;} std::vector<long long> primeFactor(long long n){ std::vector<long long> vec; for(long long i{2}; i * i <= n; ++i) if(!(n % i)){ vec.push_back(i); while(!(n % i)) n /= i; } if(n > 1) vec.push_back(n); return vec; } int main(){ std::string S; std::cin >> S; int N{int(std::size(S))}; auto primes{primeFactor(N)}; int op_num{INF}; auto ans{S}; for(auto p: primes){ int a{int(N / p)}, op{}; std::string s; std::vector cnts(a, std::vector<int>(26, 0)); for(int i{}; i < N; ++i) ++cnts[i % a][S[i] - 'A']; for(int i{}; i < a; ++i){ auto max_it{ranges::max_element(cnts[i])}; op += a - *max_it; s += char('A' + int(std::distance(std::begin(cnts[i]), max_it))); } if(chmin(op_num, op)){ ans = s; for(int i{1}; i < p; ++i) ans += s; } } std::cout << ans << std::endl; return 0; }