이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
//#define endl '\n'
llo n;
llo mod=1e9+7;
pair<llo,llo> it[1000001];
llo vis[1000001];
vector<llo> adj[1000001];
llo st=0;
void dfs(llo no,llo col=1){
vis[no]=col;
for(auto j:adj[no]){
if(vis[j]==0){
dfs(j,3-col);
}
else if(vis[j]==vis[no]){
st=1;
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for(llo i=0;i<n;i++){
cin>>it[i].a>>it[i].b;
}
for(llo i=0;i<n;i++){
for(llo j=0;j<n;j++){
if(j==i){
continue;
}
if(it[i].a<=it[j].a and it[i].b<=it[j].b and it[i].b>=it[j].a){
adj[i].pb(j);
adj[j].pb(i);
// cout<<i<<","<<j<<endl;
}
}
}
llo co=0;
for(llo i=0;i<n;i++){
if(vis[i]==0){
dfs(i);
co+=1;
}
}
if(st){
cout<<0<<endl;
}
else{
llo ans=1;
for(llo i=0;i<co;i++){
ans*=2;
ans%=mod;
}
cout<<ans<<endl;
}
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... |