제출 #69206

#제출 시각아이디문제언어결과실행 시간메모리
69206mirbek01Port Facility (JOI17_port_facility)C++17
10 / 100
3509 ms852 KiB
# include <bits/stdc++.h> using namespace std; int n, a[22], b[22], ans; int main(){ cin >> n; for(int i = 0; i < n; i ++){ cin >> a[i] >> b[i]; a[i] --, b[i] --; } for(int mask = 0; mask < (1 << n); mask ++){ vector <int> v, add[n + n], del[n + n]; for(int i = 0; i < n; i ++){ if((1 << i) & mask){ add[a[i]].push_back(i); del[b[i]].push_back(i); } } bool ok = 1; for(int i = 0; i < n * 2; i ++){ for(int j : add[i]) v.push_back(j); for(int j : del[i]){ if(v.back() != j){ ok = 0; break; } v.pop_back(); } add[i].clear(); del[i].clear(); } for(int i = 0; i < n; i ++){ if(!((1 << i) & mask)){ add[a[i]].push_back(i); del[b[i]].push_back(i); } } for(int i = 0; i < n * 2; i ++){ for(int j : add[i]) v.push_back(j); for(int j : del[i]){ if(v.back() != j){ ok = 0; break; } v.pop_back(); } } ans += ok; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...