제출 #671402

#제출 시각아이디문제언어결과실행 시간메모리
671402amunduzbaevPort Facility (JOI17_port_facility)C++17
10 / 100
475 ms464 KiB
#include "bits/stdc++.h" using namespace std; const int N = 100; int a[N], b[N], id[N], w[N]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; if(n > 20) assert(false); for(int i=0;i<n;i++){ cin >> a[i] >> b[i]; a[i]--, b[i]--; id[a[i]] = id[b[i]] = i; w[b[i]] = 1; } int res = 0; for(int mask=0;mask < (1 << n);mask++){ vector<int> p[2]; bool ok = 1; for(int i=0;i<n*2;i++){ int j = id[i]; if(w[i]){ if(p[mask >> j & 1].empty() || p[mask >> j & 1].back() != j){ ok = 0; break; } p[mask >> j & 1].pop_back(); } else { p[mask >> j & 1].push_back(j); } } if(ok) res++; } cout<<res<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...