제출 #154863

#제출 시각아이디문제언어결과실행 시간메모리
154863theboatmanSegments (IZhO18_segments)C++17
0 / 100
2 ms504 KiB
#include <bits/stdc++.h>

#define y1 theboatman
#define make_struct(args...) {args}

using namespace std;

struct osu {
    int l, r, id;
};

void solve(int n, int t) {
    vector <osu> now;
    int id = 1, lastans;

    for(int it = 0; it < n; it++) {
        int type;
        cin >> type;

        if (type == 1) {
            int a, b;
            cin >> a >> b;

            int l = (a ^ (t * lastans));
            int r = (b ^ (t * lastans));

            if (l > r) {
                swap(l, r);
            }

            now.push_back(make_struct(l, r, id++));
        }

        if (type == 2) {
            int id;
            cin >> id;

            vector <osu> new_now;
            for(auto i : now) {
                if (i.id != id) {
                    new_now.push_back(i);
                }
            }

            now = new_now;
        }

        if (type == 3) {
            int a, b, k;
            cin >> a >> b >> k;

            int l = (a ^ (t * lastans));
            int r = (b ^ (t * lastans));

            if (l > r) {
                swap(l, r);
            }

            int res = 0;
            for(auto i : now) {
                int L = max(l, i.l);
                int R = min(i.r, r);

                if (!k) {
                    res++;
                }
                else {
                    if (L <= R && R - L + 1 >= k) {
                        res++;
                    }
                }
            }

            cout << res << "\n";
            lastans = res;
        }
    }
}

void solve1(int n, int t) {
    cout << "kek\n";
}

int main() {
    cin.tie(0);
    ios :: sync_with_stdio(0);

    int n, t;
    cin >> n >> t;

    if (n <= int(5e3)) {
        solve(n, t);
    }
    else {
        solve1(n, t);
    }
    return 0;
}
/*
*/

컴파일 시 표준 에러 (stderr) 메시지

segments.cpp: In function 'void solve(int, int)':
segments.cpp:52:29: warning: 'lastans' may be used uninitialized in this function [-Wmaybe-uninitialized]
             int l = (a ^ (t * lastans));
                          ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...