제출 #1101283

#제출 시각아이디문제언어결과실행 시간메모리
1101283irmuunPort Facility (JOI17_port_facility)C++17
10 / 100
110 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin>>n; ll a[n+5],b[n+5]; vector<ll>c(2*n+5); vector<bool>in(2*n+5); for(ll i=1;i<=n;i++){ cin>>a[i]>>b[i]; c[a[i]]=i; c[b[i]]=i; in[a[i]]=true; in[b[i]]=false; } ll ans=0; vector<ll>A,B; for(ll i=0;i<(1ll<<n);i++){ ll cur=0; bool ok=true; A.clear(); B.clear(); for(ll j=1;j<=2*n;j++){ if(in[j]){ if(i&(1ll<<cur)) A.pb(c[j]); else B.pb(c[j]); cur++; } else{ if(!A.empty()&&A.back()==c[j]){ A.pop_back(); } else if(!B.empty()&&B.back()==c[j]){ B.pop_back(); } else{ ok=false; break; } } } if(ok) ans++; } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...