Submission #678703

# Submission time Handle Problem Language Result Execution time Memory
678703 2023-01-06T11:26:28 Z DanTatar Segments (IZhO18_segments) C++17
0 / 100
18 ms 1760 KB
#include <bits/stdc++.h>
#define pb push_back
#define sz(v) v.size()
#define in insert
#define ld double
#define all(v) v.begin(),v.end()
#define ent endl
#define S second
#define F first
#define int long long
#define pii pair <long long, long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*#pragma optimize ("g",on)
#pragma GCC optimize ("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
#pragma comment(linker, "/stack:200000000")*/

using namespace std;

const int INF = 1e18 + 123;
const int N = 1e4 + 123;
const int mod = 998244353;
const double PI = 3.1415926536;

const double eps = 1e-20;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

int n, t;
set <int> id;
pair <int, int> a[N];
int lst;

void solve(){
    cin >> n >> t;
    for(int i = 1; i <= n; ++i){
        id.insert(i);
        a[i] = {-1, -1};
    }
    
    for(int t1 = 0; t1 < n; ++t1){
        int type;
        cin >> type;
        if(type == 1){
            int l,r;
            cin >> l >> r;
            l = (l^(t*lst)), r = (r^(t*lst));
            
            if(l > r){
                swap(l, r);
            }
            
            int ind = *id.begin();
            id.erase(id.begin());
            a[ind] = make_pair(l, r);
        } else if(type == 2){
            int j;
            cin >> j;
            a[j] = make_pair(-1, -1);
            id.insert(j);
        } else {
            int l,r,k;
            int ans = 0;
            cin >> l >> r >> k;
            l = (l^(t*lst)), r = (r^(t*lst));
            
            if(l > r){
                swap(l, r);
            }
            
            for(int i = 1; i <= n; i++){
                int L = a[i].F, R = a[i].S;
				if(L == -1 && R == -1) continue;
				int res = 0;
				if(l <= L && R <= r) res = R-L+1;
				else if(l <= L && L <= r) res = r-L+1;
				else if(l <= R && R <= r) res = R-l+1;
				else if(L <= l && r <= R) res = r-l+1;
				else res = 0;
				if(res >= k) ans++;
			}
            
            cout << ans << ent;
            lst = ans;
        }
    }
}

signed main() {
	speed;
    int tt = 1;
    //cin >> tt;
    while(tt --){
        solve();
        cout << ent;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Incorrect 18 ms 752 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1760 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1748 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1748 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Incorrect 18 ms 752 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Incorrect 18 ms 752 KB Output isn't correct
4 Halted 0 ms 0 KB -