Submission #896851

#TimeUsernameProblemLanguageResultExecution timeMemory
896851Alihan_8Port Facility (JOI17_port_facility)C++17
0 / 100
1 ms344 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define ar array #define pb push_back #define ln '\n' #define int long long using i64 = long long; template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } const int Mod = 1e9 + 7; const int N = 2e3 + 1; bitset <N> b[N]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector <ar<int,2>> a(n); for ( auto &[l, r]: a ){ cin >> l >> r; } auto in = [&](int i, int j){ return a[i][0] <= a[j][0] && a[i][1] >= a[j][1]; }; sort(all(a)); for ( int i = 0; i < n; i++ ){ for ( int j = 0; j < n; j++ ){ if ( i == j ){ continue; } bool flg = (a[i][0] > a[j][1] || a[i][1] < a[j][0]); flg |= in(i, j) | in(j, i); b[i][j] = !flg; } } for ( int i = 0; i < n; i++ ){ for ( int j = i + 1; j < n; j++ ){ if ( b[i][j] && (b[i] & b[j]).count() ){ return cout << "0\n", 0; } } } int ans = 1; set <int> st; for ( auto &[l, r]: a ){ auto it = st.lower_bound(l); if ( !(it != st.end() && *it < r) ){ ans = ans * 2 % Mod; } st.insert(r); } cout << ans; cout << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...