Submission #1232820

#TimeUsernameProblemLanguageResultExecution timeMemory
1232820_Knyaz_Monkey and Apple-trees (IZhO12_apple)C++20
0 / 100
2095 ms564 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int M, C = 0;
    cin >> M;
    vector<bool> vec(1000010, 0);

    while (M--) {
        int D, X, Y;
        cin >> D >> X >> Y;
        int L = X + C, R = Y + C;
        if (L > R) swap(L, R);
        if (R >= 1000010) R = 1000009;

        if (D == 1) {
            int cnt = 0;
            for (int i = L; i <= R; ++i) cnt += vec[i];
            C = cnt;
            cout << C << '\n';
        } else {
            for (int i = L; i <= R; ++i) vec[i] = 1;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...