結果

問題 No.2933 Range ROT Query
ユーザー 👑 loop0919
提出日時 2024-09-09 18:26:17
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 448 ms / 3,000 ms
コード長 2,516 bytes
コンパイル時間 3,344 ms
コンパイル使用メモリ 254,920 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-10-02 00:29:08
合計ジャッジ時間 21,107 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
#include <atcoder/fenwicktree>
using namespace std;
using namespace atcoder;
const int sigma = 26;
const int emptyset = -1;
const int wildcard = 9999;
int op(int x, int y) {
if (x == emptyset || y == emptyset) {
return emptyset;
} else if (x == wildcard) {
return y;
} else if (y == wildcard) {
return x;
} else if (x == y){
return x;
} else {
return emptyset;
}
}
int e() { return wildcard; }
int mapping(int f, int x) {
if (x == emptyset || x == wildcard) {
return x;
} else {
return (f + x) % sigma;
}
}
int composition(int f, int g) { return (f + g) % sigma; }
int id_() { return 0; }
int main() {
string s, t;
cin >> s >> t;
int min_s_t = min(s.size(), t.size());
vector<int> diff(min_s_t);
for (int i = 0; i < min_s_t; i++) {
diff[i] = (s[i] - t[i] + sigma) % sigma;
}
lazy_segtree<int, op, e, int, mapping, composition, id_> seg(diff);
fenwick_tree<int> s_imos(s.size() + 1);
fenwick_tree<int> t_imos(t.size() + 1);
int q;
cin >> q;
while (q--) {
int cmd;
cin >> cmd;
if (cmd == 1) {
int l, r, x;
cin >> l >> r >> x;
seg.apply(min(l - 1, min_s_t), min(r, min_s_t), x);
s_imos.add(l - 1, x);
s_imos.add(r, sigma - x);
} else if (cmd == 2) {
int l, r, x;
cin >> l >> r >> x;
seg.apply(min(l - 1, min_s_t), min(r, min_s_t), sigma - x);
t_imos.add(l - 1, x);
t_imos.add(r, sigma - x);
} else {
int p;
cin >> p;
int idx = seg.max_right(p - 1, [&](int v) { return (v == 0 || v == wildcard); });
if (idx < min_s_t) {
int s_val = (int)(s_imos.sum(0, idx + 1) + s[idx] - 'a') % sigma;
int t_val = (int)(t_imos.sum(0, idx + 1) + t[idx] - 'a') % sigma;
if (s_val > t_val) {
cout << "Greater" << endl;
} else {
cout << "Lesser" << endl;
}
} else {
if (s.size() > t.size()) {
cout << "Greater" << endl;
} else if (s.size() < t.size()) {
cout << "Lesser" << endl;
} else {
cout << "Equals" << endl;
}
}
}
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0