Submission #1062296

#TimeUsernameProblemLanguageResultExecution timeMemory
106229612345678Port Facility (JOI17_port_facility)C++17
10 / 100
164 ms460 KiB
#include <bits/stdc++.h> using namespace std; const int nx=21; int n, l[nx], r[nx], res; pair<int, int> v[2*nx]; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n; for (int i=0; i<n; i++) cin>>l[i]>>r[i], v[l[i]]={i, 1}, v[r[i]]={i, 0}; for (int msk=0; msk<(1<<n); msk++) { stack<int> a, b; int f=0; for (int i=1; i<=2*n; i++) { if (v[i].second) { if (msk&(1<<v[i].first)) a.push(v[i].first); else b.push(v[i].first); } else { if (msk&(1<<v[i].first)) { if (a.top()!=v[i].first) { f=1; break; } else a.pop(); } else { if (b.top()!=v[i].first) { f=1; break; } else b.pop(); } } } if (!f) res++; } cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...