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;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
/*
is I know the division, checking will be if there a segment that intersegt and not entirly contain.
*/
const int MOD = 1e9+7;
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n;cin>>n;
if(n>20) return 0;
vector<pair<int,int> > seg(n+1);
for(int i=1;i<=n;i++) cin>>seg[i].first>>seg[i].second;
vector<int> action(2*n+1);
for(int i=1;i<=n;i++){
action[seg[i].first]=i;
action[seg[i].second]=-i;
}
sort(seg.begin(),seg.end());
int ans=0;
for(int m=0;m<(1<<n);m++){
bool ok=1;
stack<int> f[2];
for(int i=1;i<=2*n;i++){
bool k = (m>>(abs(action[i])-1))&1;
if(action[i]>0){
f[k].push(action[i]);
}else{
if(f[k].top()!=-action[i]){
ok=0;
break;
}
f[k].pop();
}
}
if(ok) ans++;
}
cout<<ans<<"\n";
return 0;
}
# | 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... |