제출 #667063

#제출 시각아이디문제언어결과실행 시간메모리
667063Kaztaev_AlisherSegments (IZhO18_segments)C++17
7 / 100
5082 ms3092 KiB
//#pragma GCC optomize ("Ofast")
//#pragma GCC optomize ("unroll-loops")
//#pragma GCC target ("avx,avx2,fma")

#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define sz size
#define cl clear
#define ins insert
#define ers erase
#define pii pair < int , int >
#define pll pair< long long  , long long >
#define all(x) x.begin() , x.end()
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define tostr(x) to_string(x)
#define tonum(s) atoi(s.c_str())
#define seon(x) setprecision(x)
#define bpop(x) __builtin_popcount(x)
#define deb(x) cerr << #x  << " = " << x << endl;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
const double PI = 3.14159265;

const ll N = 1e5+5;
const ll mod = 1e9+7;
const ll inf = 1e9;
const ll INF = 1e18;

using namespace std;

pii p[N];
bool was[N];
void solve(){
	int n , t;
	cin >> n >> t;
	int cnt = 0 , lst = 0;
	while(n--){
		int tp ;
		cin >> tp;
		if(tp == 1){
			int l , r;
			cin >> l >> r;
			l = (l ^ (t*lst));
			r = (r ^ (t*lst));
			if(l > r)swap(l,r);
			p[++cnt] = {l , r};
		} else if (tp == 2){
			int id;
			cin >> id;
			was[id] = 1;
		} else {
			int l , r , ans = 0 , k;
			cin >> l >> r >> k;
			l = (l ^ (t*lst));
			r = (r ^ (t*lst));
			if(l > r) swap(l,r);
			for(int i = 1; i <= cnt; i++){
				if(was[i] == 1) continue;
				int L = p[i].F , R = p[i].S , 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++;
			}
			lst = ans;
			cout << ans <<"\n";
		}
	}
}
signed main(){
	ios;
	solve();
	return 0;
}
/*
6 0
1 3 10
1 3 5

3 6 10 6

2 1

1 3 10

3 6 4 2
*/
#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...