Submission #832542

#TimeUsernameProblemLanguageResultExecution timeMemory
832542LucaIliePort Facility (JOI17_port_facility)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; struct container { int l, r; bool operator < ( container c ) { return l < c.l; } }; const int MAX_N = 1e6; const int MOD = 1e9 + 7; int side[MAX_N]; container containers[MAX_N]; int main() { int n; cin >> n; for ( int i = 0; i < n; i++ ) cin >> containers[i].l >> containers[i].r; sort( containers, containers + n ); int comp = 0; bool bipartit = true; for ( int i = 0; i < n; i++ ) { side[i] = -1; for ( int j = 0; j < i; j++ ) { if ( containers[j].r > containers[i].l && containers[j].r < containers[i].r ) { if ( side[i] == side[j] ) bipartit = false; else side[i] = side[j] ^ 1; } } if ( side[i] == -1 ) { comp++; side[i] = 0; } } if ( bipartit ) { int ans = 1; for ( int i = 0; i < comp; i++ ) ans = ans * 2 % MOD; cout << ans; } else cout << 0; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...