結果
| 問題 |
No.8015 アンチローリングハッシュ
|
| ユーザー |
|
| 提出日時 | 2024-05-17 02:05:34 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 839 bytes |
| コンパイル時間 | 1,175 ms |
| コンパイル使用メモリ | 109,244 KB |
| 実行使用メモリ | 13,844 KB |
| 最終ジャッジ日時 | 2024-12-20 11:26:10 |
| 合計ジャッジ時間 | 5,130 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 7 WA * 14 |
ソースコード
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for (ll i = j; i < (n); ++i)
#define rrep(i, j, n) for (ll i = (n) - 1; j <= i; --i)
#define all(a) a.begin(), a.end()
int main() {
cin.tie(0)->sync_with_stdio(0);
ll a, b;
cin >> a >> b;
string s;
char c = 0;
rep(i, 0, b * 10) {
s += c + 'a';
c = (c + 1) % 26;
}
int n = (int)s.size();
vector<ll> hash(n + 1);
rep(i, 0, n) { hash[i + 1] = (hash[i] * a + s[i]) % b; }
vector<ll> mp(b);
rep(i, 0, n) mp[hash[i]]++;
ll mx = 0, mxi = 0;
rep(i, 0, b) if (mx < mp[i]) mx = mp[i], mxi = i;
vector<int> ids;
rep(i, 0, n) if (hash[i] == mxi) ids.push_back(i);
string t = s;
reverse(t.begin() + ids[0], t.begin() + ids[1]);
cout << s << '\n' << t << '\n';
}