結果

問題 No.2933 Range ROT Query
ユーザー loop0919loop0919
提出日時 2024-08-27 23:23:05
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 613 ms / 3,000 ms
コード長 2,536 bytes
コンパイル時間 3,353 ms
コンパイル使用メモリ 255,324 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-10-02 00:23:35
合計ジャッジ時間 28,672 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 2 ms
5,248 KB
testcase_05 AC 2 ms
5,248 KB
testcase_06 AC 2 ms
5,248 KB
testcase_07 AC 2 ms
5,248 KB
testcase_08 AC 2 ms
5,248 KB
testcase_09 AC 2 ms
5,248 KB
testcase_10 AC 2 ms
5,248 KB
testcase_11 AC 2 ms
6,816 KB
testcase_12 AC 481 ms
15,488 KB
testcase_13 AC 476 ms
15,360 KB
testcase_14 AC 473 ms
15,360 KB
testcase_15 AC 474 ms
15,488 KB
testcase_16 AC 472 ms
15,360 KB
testcase_17 AC 534 ms
15,360 KB
testcase_18 AC 543 ms
15,360 KB
testcase_19 AC 546 ms
15,360 KB
testcase_20 AC 553 ms
15,360 KB
testcase_21 AC 422 ms
15,360 KB
testcase_22 AC 419 ms
15,488 KB
testcase_23 AC 421 ms
15,488 KB
testcase_24 AC 421 ms
15,488 KB
testcase_25 AC 427 ms
15,360 KB
testcase_26 AC 600 ms
15,360 KB
testcase_27 AC 602 ms
15,360 KB
testcase_28 AC 601 ms
15,488 KB
testcase_29 AC 595 ms
15,360 KB
testcase_30 AC 594 ms
15,488 KB
testcase_31 AC 613 ms
15,360 KB
testcase_32 AC 456 ms
14,592 KB
testcase_33 AC 523 ms
11,392 KB
testcase_34 AC 537 ms
11,264 KB
testcase_35 AC 355 ms
11,520 KB
testcase_36 AC 553 ms
11,520 KB
testcase_37 AC 371 ms
11,264 KB
testcase_38 AC 363 ms
14,720 KB
testcase_39 AC 441 ms
11,648 KB
testcase_40 AC 463 ms
11,648 KB
testcase_41 AC 500 ms
14,848 KB
testcase_42 AC 377 ms
9,472 KB
testcase_43 AC 439 ms
9,472 KB
testcase_44 AC 535 ms
11,264 KB
testcase_45 AC 488 ms
14,848 KB
testcase_46 AC 585 ms
11,136 KB
testcase_47 AC 475 ms
11,264 KB
testcase_48 AC 371 ms
14,720 KB
testcase_49 AC 472 ms
14,976 KB
testcase_50 AC 404 ms
11,648 KB
testcase_51 AC 506 ms
14,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/lazysegtree>

using namespace std;
using namespace atcoder;

int sigma = 26;

int op(int x, int y) { return x & y; }
int e() { return (1 << sigma) - 1; }
int mapping(int f, int x) { return ((x << f) & ((1 << sigma) - 1)) | (x >> (sigma - f)); }
int composition(int f, int g) { return (f + g) % sigma; }
int id_() { return 0;}

int op_ord(int x, int y) { return x + y; }
int e_ord() { return 0; }
int mapping_ord(int f, int x) { return (f + x) % sigma; }
int composition_ord(int f, int g) { return (f + g) % sigma; }
int id_ord() { return 0; }

int main() {
    string s, t;
    cin >> s >> t;

    int min_st = min(s.size(), t.size());

    vector<int> diff_bitset(min_st);
    for (int i = 0; i < min(s.size(), t.size()); i++) {
        diff_bitset[i] = 1 << ((s[i] - t[i] + 26) % 26);
    }

    lazy_segtree<int, op, e, int, mapping, composition, id_> seg_diff_set(diff_bitset);

    vector<int> ord_s(s.size());
    for (int i = 0; i < s.size(); i++) {
        ord_s[i] = (int)(s[i] - 'a');
    }
    
    vector<int> ord_t(t.size());
    for (int i = 0; i < t.size(); i++) {
        ord_t[i] = (int)(t[i] - 'a');
    }

    lazy_segtree<int, op_ord, e_ord, int, mapping_ord, composition_ord, id_ord> seg_s(ord_s);
    lazy_segtree<int, op_ord, e_ord, int, mapping_ord, composition_ord, id_ord> seg_t(ord_t);

    int q;
    cin >> q;

    while (q--) {
        int cmd;
        cin >> cmd;

        if (cmd == 1) {
            int l, r, x;
            cin >> l >> r >> x;

            seg_diff_set.apply(min(l - 1, min_st), min(r, min_st), x);
            seg_s.apply(l - 1, r, x);
        } else if (cmd == 2) {
            int l, r, x;
            cin >> l >> r >> x;

            seg_diff_set.apply(min(l - 1, min_st), min(r, min_st), sigma - x);
            seg_t.apply(l - 1, r, x);
        } else {
            int p;
            cin >> p;

            int idx = seg_diff_set.max_right(p - 1, [&](int x) { return x & 1 == 1; });

            if (idx >= min_st) {
                if (s.size() > t.size()) {
                    cout << "Greater" << endl;
                } else if (s.size() < t.size()) {
                    cout << "Lesser" << endl;
                } else {
                    cout << "Equals" << endl;
                }
            } else {
                if (seg_s.get(idx) > seg_t.get(idx)) {
                    cout << "Greater" << endl;
                } else {
                    cout << "Lesser" << endl;
                }
            }
        }
    }
}
0