제출 #953451

#제출 시각아이디문제언어결과실행 시간메모리
953451pccPort Facility (JOI17_port_facility)C++17
22 / 100
27 ms16488 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...