結果
| 問題 | No.1171 Runs in Subsequences |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-29 14:02:48 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 305 ms / 2,000 ms |
| + 4µs | |
| コード長 | 1,155 bytes |
| 記録 | |
| コンパイル時間 | 2,114 ms |
| コンパイル使用メモリ | 336,332 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-15 07:46:36 |
| 合計ジャッジ時間 | 5,903 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/vector:67,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/functional:66,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:55,
from main.cpp:4:
In function '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = long long int*; _ForwardIterator = long long int*]',
inlined from 'constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _Sentinel, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = long long int*; _Sentinel = long long int*; _ForwardIterator = long long int*; _Tp = long long int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/stl_uninitialized.h:635:32,
inlined from 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/vector.tcc:257:35,
inlined from 'int main()' at main.cpp:47:13:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/stl_uninitialized.h:273:31: warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' writing between 1 and 1024 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
273 | __builtin_memcpy(std::__niter_base(__result),
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
274 | std::__niter_base(__first),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
275 | __n * sizeof(_ValT));
| ~~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/c++
ソースコード
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>
using std::cin, std::cout, std::cerr;
using ll = long long;
const ll P = 1e9 + 7;
ll Pow(ll a, ll b) {
ll r = 1;
for(; b; b /= 2) {
if(b & 1)
r = r * a % P;
a = a * a % P;
}
return r;
}
int main() {
std::ios::sync_with_stdio(false);
std::string s; cin >> s;
auto upd = [](ll &a, ll b) {
a += b;
a %= P;
};
std::vector<ll> f(128);
ll ans = 0;
int n = s.size();
for(int i = 0; i < n; i ++) {
char c = s[i];
std::vector<ll> g(128, 0);
upd(g[c], 1);
upd(ans, Pow(2, n - i - 1));
for(char t = 'a'; t <= 'z'; t ++) {
if(t != c) {
upd(g[t], f[t]);
upd(ans, f[t] * Pow(2, n - i - 1));
upd(g[c], f[t]);
} else {
upd(g[t], 2 * f[t]);
}
}
// cout << "------\n";
// cout << g['a'] << ' ' << g['b'] << ' ' << ans << '\n';
f = g;
}
cout << ans << '\n';
}