# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
69131 | Just_Solve_The_Problem | Port Facility (JOI17_port_facility) | C++11 | 940 ms | 748 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;
pii ar[N];
int st[30];
int ans;
main() {
int n;
scanf("%d", &n);
assert(n <= 20);
vector < int > v1(n + n + 1);
for (int i = 0; i < n; i++) {
scanf("%d %d", &ar[i].fr, &ar[i].sc);
v1[ar[i].fr] = i;
v1[ar[i].sc] = i + n;
}
for (int mask = 0; mask < (1 << n); mask++) {
vector < int > stk[2];
bool ok = 1;
for (int i = 1; i <= n + n; i++) {
int bit = (mask >> (v1[i] % n)) & 1;
if (v1[i] >= n) {
if (stk[bit].back() == v1[i] - n) {
stk[bit].pop_back();
} else {
ok = 0;
}
} else {
stk[bit].pb(v1[i]);
}
}
ans += ok;
}
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... |