結果
| 問題 |
No.2761 Substitute and Search
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2024-05-17 22:11:23 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,976 bytes |
| コンパイル時間 | 3,765 ms |
| コンパイル使用メモリ | 282,452 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-20 14:03:51 |
| 合計ジャッジ時間 | 7,266 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 RE * 12 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
int conv[1010][26];
int inv[1010][26];
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, l, q;
cin >> n >> l >> q;
vector<string> s(n);
rep(i, n) cin >> s[i];
sort(all(s));
rep(j, l) rep(c, 26) conv[j][c] = inv[j][c] = c;
rep(_, q) {
int type;
cin >> type;
if (type == 1) {
int k;
char c, d;
cin >> k >> c >> d;
k--;
int ci = c - 'a', di = d - 'a';
if (inv[k][ci] == -1) continue;
if (inv[k][di] == -1) {
int x = inv[k][ci];
inv[k][ci] = -1;
inv[k][di] = x;
conv[k][x] = di;
} else {
int x = inv[k][ci];
int y = inv[k][di];
rep(i, n) if (s[i][k] - 'a' == x) s[i][k] = 'a' + y;
sort(all(s));
conv[k][x] = inv[k][ci] = -1;
}
} else {
string t;
cin >> t;
bool ok = true;
rep(j, ssize(t)) {
if (inv[j][t[j] - 'a'] == -1) {
ok = false;
break;
}
t[j] = 'a' + inv[j][t[j] - 'a'];
}
if (!ok) {
cout << 0 << '\n';
} else {
auto from = lower_bound(all(s), t);
t.back()++;
auto to = lower_bound(all(s), t);
cout << to - from << '\n';
}
}
}
}
Kude