Submission #944256

# Submission time Handle Problem Language Result Execution time Memory
944256 2024-03-12T13:01:25 Z dilanyan Segments (IZhO18_segments) C++17
0 / 100
5000 ms 3824 KB
//-------------dilanyan------------\\ 
 
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
 
//------------------KarginDefines--------------------\\ 
 
#define ll long long
#define pb push_back
#define all(u) (u).begin(), (u).end()
#define pqueue priority_queue
#define upper upper_bound
#define lower lower_bound
#define umap unordered_map
#define uset unordered_set
#define Kargin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Usaco freopen(".in", "r", stdin); freopen(".out", "w", stdout);
 
 
//-------------------KarginConstants------------------\\ 
 
const ll mod = 1000000007;
const ll inf = 2e9;
 
//-------------------KarginCode------------------------\\ 
 
const int N = 200005;

void KarginSolve() {
    int n, t;
    cin >> n >> t;
    multiset<pair<int, pair<int, int>>> mst;
    set<int> st;
    int lastans = 0;
    for (int i = 0;i < n;i++) {
        int type; cin >> type;
        if (type == 1) {
            int a, b;
            cin >> a >> b;
            int l = a ^ (t * lastans), r = b ^ (t * lastans);
            if (l > r) swap(l, r);
            int i = 1;
            for (int x : st) {
                if (x == i) i++;
                else break;
            }
            mst.insert({ i,{l,r} });
        }
        else if (type == 2) {
            int id; cin >> id;
            st.erase(st.find(id));
            for (auto it = mst.begin(); it != mst.end();++it) {
                if ((*it).first == id) {
                    mst.erase(it);
                    break;
                }
            }
        }
        else {
            int a, b, k;
            cin >> a >> b >> k;
            int l = a ^ (t * lastans), r = b ^ (t * lastans);
            if (l > r) swap(l, r);
            int ans = 0;
            for (auto it : mst) {
                int lx = it.second.first, rx = it.second.second;
                bool flag = true;
                if (lx > l) swap(lx, l), swap(rx, r), flag = false;
                if (l > rx || r < lx);
                else if (l >= lx && r <= rx) ans += (r - l + 1 >= k);
                else ans += (rx - l + 1 >= k);
                if (!flag) swap(lx, l), swap(rx, r);
            }
            cout << ans << '\n';
            lastans = ans;
        }
    }
}
 
int main() {
    //Usaco
    Kargin;
    int test = 1;
    //cin >> test;
    while (test--) {
        KarginSolve();
    }
    return 0;
}

Compilation message

segments.cpp:1:1: warning: multi-line comment [-Wcomment]
    1 | //-------------dilanyan------------\\
      | ^
segments.cpp:8:1: warning: multi-line comment [-Wcomment]
    8 | //------------------KarginDefines--------------------\\
      | ^
segments.cpp:22:1: warning: multi-line comment [-Wcomment]
   22 | //-------------------KarginConstants------------------\\
      | ^
segments.cpp:27:1: warning: multi-line comment [-Wcomment]
   27 | //-------------------KarginCode------------------------\\
      | ^
# Verdict Execution time Memory Grader output
1 Execution timed out 5049 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5016 ms 3824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5046 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5042 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5049 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5049 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -