제출 #1370021

#제출 시각아이디문제언어결과실행 시간메모리
1370021kawhietSegments (IZhO18_segments)C++20
7 / 100
5092 ms5352 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif

array<int, 2> get(array<int, 2> x, array<int, 2> y) {
    return {max(x[0], y[0]), min(x[1], y[1])};
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, t;
    cin >> n >> t;
    map<int, array<int, 2>> m;
    int id = 1, ans = 0;
    while (n--) {
        int c;
        cin >> c;
        if (c == 1) {
            int a, b;
            cin >> a >> b;
            int l = a ^ (t * ans);
            int r = b ^ (t * ans);
            if (l > r) swap(l, r);
            m[id] = {l, r};
            id++;
        } else if (c == 2) {
            int i;
            cin >> i;
            m.erase(i);
        } else {
            int a, b, k;
            cin >> a >> b >> k;
            int l = a ^ (t * ans);
            int r = b ^ (t * ans);
            if (l > r) swap(l, r);
            int ans_nw = 0;
            for (auto [i1, x] : m) {
                array<int, 2> z = get({l, r}, x);
                if (z[1] - z[0] + 1 >= k) {
                    ans_nw++;
                }
            }
            swap(ans, ans_nw);
            cout << ans << '\n';
        }
    }
    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…