This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
set <int> s;
multiset <pair<int,pii> > m;
pii p[N];
int der[N];
set <int> ss;
int mex(){
for(int i=1;i<=5001;++i){
if (!ss.count(i))ret i;
}
}
/*
void build(int v,int l,int r){
if (l == r){
der[v] = l;
ret ;
}
else {
int m = l+r>>1;
build(v<<1,l,m);
build((v<<1)+1,m+1,r);
der[v] = min(der[v<<1],der[(v<<1)+1]);
}
}
void update(int v,int l,int r,int x,int y){
if (l == x && r == x){
der[v] = y;
ret ;
}
else {
int m = l+r>>1;
if (m < x){
update((v<<1)+1,m+1,r,x,y);
}
else {
update(v<<1,l,m,x,y);
}
der[v] = min(der[v<<1],der[(v<<1)+1]);
}
}
*/
int fun(pii a,pii b){
if (a.sc < b.fr || a.fr > b.sc)ret 0;
ret min(a.sc,b.sc)-max(a.fr,b.fr)+1;
}
main(){
int n,t,i,j,lastans=0;
scan2(n,t)
//build(1,1,200000);
for (j=1;j<=n;++j){
int type;
scan1(type)
if (type == 1){
int x = mex(),l,r;
scan2(l,r)
ss.insert(x);
//update(1,1,200000,x,INF);
l = (l^(t*lastans));
r = (r^(t*lastans));
if (l > r)swap(l,r);
p[x] = {l,r};
m.insert({x,{l,r}});
}
if (type == 2){
int id;
scan1(id)
//update(1,1,200000,id,id);
s.erase(id);
m.erase({id,{p[id].fr,p[id].sc}});
}
if (type == 3){
int l,r,k,ans=0;
scan3(l,r,k)
l = (l^(t*lastans));
r = (r^(t*lastans));
if (l > r)swap(l,r);
for (auto it: m){
pii x = it.sc;
if (fun({l,r},x) >= k)ans++;
}
cout <<ans<<"\n";
lastans=ans;
}
}
}
Compilation message (stderr)
segments.cpp:63:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
63 | main(){
| ^
segments.cpp: In function 'int main()':
segments.cpp:64:13: warning: unused variable 'i' [-Wunused-variable]
64 | int n,t,i,j,lastans=0;
| ^
segments.cpp: In function 'long long int mex()':
segments.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type]
25 | }
| ^
segments.cpp: In function 'int main()':
segments.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
segments.cpp:65:5: note: in expansion of macro 'scan2'
65 | scan2(n,t)
| ^~~~~
segments.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
9 | #define scan1(a) scanf("%lld",&a);
| ~~~~~^~~~~~~~~~~
segments.cpp:69:9: note: in expansion of macro 'scan1'
69 | scan1(type)
| ^~~~~
segments.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
segments.cpp:72:13: note: in expansion of macro 'scan2'
72 | scan2(l,r)
| ^~~~~
segments.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
9 | #define scan1(a) scanf("%lld",&a);
| ~~~~~^~~~~~~~~~~
segments.cpp:83:13: note: in expansion of macro 'scan1'
83 | scan1(id)
| ^~~~~
segments.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
11 | #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
segments.cpp:90:13: note: in expansion of macro 'scan3'
90 | scan3(l,r,k)
| ^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |