結果
| 問題 |
No.2761 Substitute and Search
|
| コンテスト | |
| ユーザー |
maeshun
|
| 提出日時 | 2024-05-19 14:10:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,979 bytes |
| コンパイル時間 | 4,351 ms |
| コンパイル使用メモリ | 258,156 KB |
| 最終ジャッジ日時 | 2025-02-21 15:58:52 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 TLE * 1 -- * 10 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
# include <debug_print.hpp>
# define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
# define dbg(...) (static_cast<void>(0))
#endif
////segtreeに乗せる用
long long mod = 2147483647;
struct S {
long long hash, pow;
};
S op(S a, S b){
long long na = a.hash * b.pow + b.hash;
na %= mod;
return {na, (a.pow * b.pow) % mod};
}
S e(){
return {0,1};
}
int main()
{
int n, l, q;
cin >> n >> l >> q;
segtree<S, op, e> tmp(l);
vector<segtree<S, op, e>> seg;
vector<string> s(n);
rep(i,n) {
cin >> s[i];
vector<S> tmp(l);
rep(j,l) {
S t;
t.hash = s[i][j] - 'a';
t.pow = 1001;
tmp[j] = t;
}
segtree<S, op, e> t(tmp);
seg.push_back(t);
}
while(q--) {
int t;
cin >> t;
if(t==1) {
int k;
char c, d;
cin >> k >> c >> d;
--k;
rep(i,n) {
if(s[i][k]==c) {
s[i][k] = d;
S r;
r.hash = d - 'a';
r.pow = 1001;
seg[i].set(k, r);
}
}
}
else{
string t;
cin >> t;
int ans = 0;
int m = t.size();
ll hs = 0;
rep(j,m) {
hs *= 1001;
hs += t[j]-'a';
hs %= mod;
}
rep(i,n) {
if(seg[i].prod(0, m).hash == hs) ans++;
}
cout << ans << "\n";
}
}
dbg(s);
return 0;
}
maeshun