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;
int main() {
// cin.tie(0)->sync_with_stdio(0);
// cin.exceptions(cin.failbit);
int n;
cin >> n;
vector<pair<int, int>> vpii(n);
struct event {
int tim;
bool ins;
int val;
event() { tim = -1, ins = 0, val = -1; }
event(int a, int b, int c) { tim = a, ins = b, val = c; }
bool operator<(event x) const { return tim < x.tim; }
};
vector<event> times; // tim id
for (int i = 0; i < vpii.size(); i++) {
cin >> vpii[i].first >> vpii[i].second;
times.emplace_back(vpii[i].first, 1, i);
times.emplace_back(vpii[i].second, 0, i);
}
sort(times.begin(), times.end());
int ct = 0;
for (int i = 0; i < (1 << n); i++) {
vector<int> A, B;
for (auto a : times)
if (a.ins) {
if (i & (1 << a.val)) {
A.push_back(a.val);
} else {
B.push_back(a.val);
}
} else {
if (!A.empty())
if (A.back() == a.val) {
A.pop_back();
goto B;
}
if (!B.empty())
if (B.back() == a.val) {
B.pop_back();
goto B;
}
goto A;
B:;
}
ct++;
A:;
}
cout << ct << "\n";
}
Compilation message (stderr)
port_facility.cpp: In function 'int main()':
port_facility.cpp:18:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for (int i = 0; i < vpii.size(); i++) {
| ~~^~~~~~~~~~~~~
# | 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... |