結果
| 問題 |
No.3239 Omnibus
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-15 21:44:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,383 bytes |
| コンパイル時間 | 1,146 ms |
| コンパイル使用メモリ | 85,544 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-15 21:51:53 |
| 合計ジャッジ時間 | 113,640 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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];
long long query(int l, int r) {
int x = a[0] + (a[1] << 8) + (a[2] << 16);
long long ans = 0, bns = 0, cns = 0, dns = 0, ens = 0, fns = 0, gns = 0,
hns = 0;
#define f(i) S[i] + (S[i + 1] << 8) + (S[i + 2] << 16)
int i = l;
for (; i + 10 < r; i += 4) {
bool cond0 = x == f(i + 0);
bool cond1 = x == f(i + 1);
bool cond2 = x == f(i + 2);
bool cond3 = x == f(i + 3);
ans += cond0 ? i : 0;
bns += cond0 ? 1 : 0;
cns += cond1 ? i + 1 : 0;
dns += cond1 ? 1 : 0;
ens += cond2 ? i + 2 : 0;
fns += cond2 ? 1 : 0;
gns += cond3 ? i + 3 : 0;
hns += cond3 ? 1 : 0;
}
for (; i + 2 < r; i++) {
bool cond = x == f(i);
ans += cond ? i : 0;
bns += cond ? 1 : 0;
}
return (ans + cns + ens + gns) - (bns + dns + fns + hns) * (l - 1);
}
int main() {
#ifdef NyaanLocal
Timer timer;
#endif
cin >> N >> Q >> S;
while (Q--) {
int cmd;
cin >> cmd;
if (cmd == 1) {
int k;
char x;
cin >> k >> x;
k--;
S[k] = x;
} else {
int l, r;
cin >> l >> r >> a;
--l;
cout << query(l, r) << "\n";
}
}
#ifdef NyaanLocal
cerr << timer() << endl;
#endif
}