Submission #667165

# Submission time Handle Problem Language Result Execution time Memory
667165 2022-11-30T15:45:48 Z Kaztaev_Alisher Segments (IZhO18_segments) C++17
7 / 100
5000 ms 3832 KB
//#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;
#define int ll 
 
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;
 
pll 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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 5 ms 340 KB Output is correct
4 Correct 5 ms 468 KB Output is correct
5 Correct 27 ms 512 KB Output is correct
6 Correct 36 ms 448 KB Output is correct
7 Correct 14 ms 468 KB Output is correct
8 Correct 19 ms 468 KB Output is correct
9 Correct 20 ms 480 KB Output is correct
10 Correct 8 ms 524 KB Output is correct
11 Correct 46 ms 468 KB Output is correct
12 Correct 45 ms 488 KB Output is correct
13 Correct 9 ms 468 KB Output is correct
14 Correct 20 ms 488 KB Output is correct
15 Correct 5 ms 468 KB Output is correct
16 Correct 4 ms 468 KB Output is correct
17 Correct 20 ms 496 KB Output is correct
18 Correct 13 ms 592 KB Output is correct
19 Correct 18 ms 468 KB Output is correct
20 Correct 19 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5039 ms 2944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 500 ms 2796 KB Output is correct
2 Correct 424 ms 2844 KB Output is correct
3 Correct 630 ms 2800 KB Output is correct
4 Correct 474 ms 2776 KB Output is correct
5 Execution timed out 5024 ms 3712 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 429 ms 2932 KB Output is correct
2 Correct 449 ms 2920 KB Output is correct
3 Correct 432 ms 3000 KB Output is correct
4 Correct 451 ms 3132 KB Output is correct
5 Execution timed out 5040 ms 3832 KB Time limit exceeded
6 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 Correct 5 ms 340 KB Output is correct
4 Correct 5 ms 468 KB Output is correct
5 Correct 27 ms 512 KB Output is correct
6 Correct 36 ms 448 KB Output is correct
7 Correct 14 ms 468 KB Output is correct
8 Correct 19 ms 468 KB Output is correct
9 Correct 20 ms 480 KB Output is correct
10 Correct 8 ms 524 KB Output is correct
11 Correct 46 ms 468 KB Output is correct
12 Correct 45 ms 488 KB Output is correct
13 Correct 9 ms 468 KB Output is correct
14 Correct 20 ms 488 KB Output is correct
15 Correct 5 ms 468 KB Output is correct
16 Correct 4 ms 468 KB Output is correct
17 Correct 20 ms 496 KB Output is correct
18 Correct 13 ms 592 KB Output is correct
19 Correct 18 ms 468 KB Output is correct
20 Correct 19 ms 468 KB Output is correct
21 Execution timed out 5039 ms 2944 KB Time limit exceeded
22 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 Correct 5 ms 340 KB Output is correct
4 Correct 5 ms 468 KB Output is correct
5 Correct 27 ms 512 KB Output is correct
6 Correct 36 ms 448 KB Output is correct
7 Correct 14 ms 468 KB Output is correct
8 Correct 19 ms 468 KB Output is correct
9 Correct 20 ms 480 KB Output is correct
10 Correct 8 ms 524 KB Output is correct
11 Correct 46 ms 468 KB Output is correct
12 Correct 45 ms 488 KB Output is correct
13 Correct 9 ms 468 KB Output is correct
14 Correct 20 ms 488 KB Output is correct
15 Correct 5 ms 468 KB Output is correct
16 Correct 4 ms 468 KB Output is correct
17 Correct 20 ms 496 KB Output is correct
18 Correct 13 ms 592 KB Output is correct
19 Correct 18 ms 468 KB Output is correct
20 Correct 19 ms 468 KB Output is correct
21 Execution timed out 5039 ms 2944 KB Time limit exceeded
22 Halted 0 ms 0 KB -