#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fs first
#define sc second
#define ll long long
const ll mod = 1e9+7;
const int mxn = 2024;
ll pw(ll a,ll b){
ll re = 1;
while(b){
if(b&1)re = re*a%mod;
b>>=1;
a = a*a%mod;
}
return re;
}
ll mad(ll a,ll b){
a += b;
return a>=mod?a-mod:a;
}
pii arr[mxn];
int N;
vector<int> paths[mxn];
int col[mxn];
bool dfs(int now,int c = 1){
bool flag = true;
col[now] = c;
for(auto nxt:paths[now]){
if(!col[nxt])flag = flag&&dfs(nxt,-c);
else if(col[nxt] != -c)flag = false;
}
return flag;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N;
for(int i = 1;i<=N;i++)cin>>arr[i].fs>>arr[i].sc;
for(int i = 1;i<=N;i++){
for(int j = i+1;j<=N;j++){
auto ta = arr[i],tb = arr[j];
if(ta.fs>tb.fs)swap(ta,tb);
if(ta.sc<tb.sc&&ta.sc>tb.fs){
paths[i].push_back(j);
paths[j].push_back(i);
}
}
}
ll ans = 1;
for(int i = 1;i<=N;i++){
if(!col[i]){
if(dfs(i)){
ans = mad(ans,ans);
}
else ans = 0;
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2035 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2035 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |