結果
| 問題 |
No.3239 Omnibus
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-15 21:52:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,041 bytes |
| コンパイル時間 | 961 ms |
| コンパイル使用メモリ | 82,480 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-15 21:55:55 |
| 合計ジャッジ時間 | 68,609 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 32 TLE * 1 |
ソースコード
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#include <iostream>
#ifdef NyaanLocal
#include "misc/timer.hpp"
#endif
using namespace std;
int N, Q;
char S[200200], a[4];
int A[200200];
void update(int k) {
if (0 <= k and k + 2 < N) A[k] = S[k] + (S[k + 1] << 8) + (S[k + 2] << 16);
}
long long query(int l, int r) {
int x = a[0] + (a[1] << 8) + (a[2] << 16);
long long ans = 0, bns = 0;
for (int i = l; i + 2 < r; i++) {
bool cond = x == A[i];
ans += cond ? i : 0;
bns += cond ? 1 : 0;
}
return ans - bns * (l - 1);
}
int main() {
#ifdef NyaanLocal
Timer timer;
#endif
cin >> N >> Q >> S;
for (int i = 0; i + 2 < N; i++) update(i);
while (Q--) {
int cmd;
cin >> cmd;
if (cmd == 1) {
int k;
char x;
cin >> k >> x;
k--;
S[k] = x;
update(k - 2), update(k - 1), update(k);
} else {
int l, r;
cin >> l >> r >> a;
--l;
cout << query(l, r) << "\n";
}
}
#ifdef NyaanLocal
cerr << timer() << endl;
#endif
}