# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
69201 | Just_Solve_The_Problem | Port Facility (JOI17_port_facility) | C++11 | 2 ms | 248 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define OK puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");
const int N = (int)1e6 + 7;
const int inf = (int)1e9 + 7;
int mod = (int)1e9 + 7;
pii ar[N];
int ans;
int div2;
int dp[N];
int pr[N];
int used[N];
int mult(int a, int b) {
return (a * 1LL * b) % mod;
}
int binpow(int a, int n) {
int res = 1;
while (n > 0) {
if (n & 1)
res = mult(res, a);
a = mult(a, a);
n >>= 1;
}
return res;
}
main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &ar[i].fr, &ar[i].sc);
}
sort(ar, ar + n);
int ans = 1;
dp[0] = 2;
for (int i = 1; i < n; i++) {
dp[i] = 2;
int last = -1;
vector < int > stk;
for (int j = 0; j < i; j++) {
if (ar[j].sc > ar[i].fr && ar[j].sc < ar[i].sc) {
if (last != -1 && ar[last].sc < ar[j].sc) ans = 0;
dp[i] = 1;
if (dp[j] == 2)
stk.pb(j);
if (last != -1 && !stk.empty()) {
dp[stk.back()] = 1;
stk.pop_back();
}
last = j;
}
}
}
// for (int i = 0; i < n; i++) {
// cout << dp[i] << ' ';
// }
// cout << endl;
for (int i = 0; i < n; i++) {
if (dp[i] == 0) continue;
ans = mult(ans, dp[i]);
}
cout << ans;
}
Compilation message (stderr)
# | 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... |