Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- //#define int long long
- int n;
- int ans=0;
- int a_sz;
- int b_sz;
- int c_sz;
- int mp[2][35];
- vector<int> as;
- vector<int> bs;
- vector<int> tp;
- vector<int> used;
- void rec(int pos,int last_up,int last_down){
- if(pos==n){
- ans++;
- for(int i=0;i<2;i++){
- for(int j=0;j<n;j++){
- cout << mp[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- return;
- }
- for(int i=last_up+1;i<=2*n;i++){
- if(used[i]) continue;
- if(tp[i]==1) continue;
- for(int j=max(i+1,last_down+1);j<=2*n;j++){
- if(used[j]) continue;
- if(tp[j]==0) continue;
- used[i]=1;
- used[j]=1;
- mp[0][pos]=i;
- mp[1][pos]=j;
- rec(pos+1,i,j);
- used[i]=0;
- used[j]=0;
- }
- }
- }
- signed main(){
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cin >> n;
- used.resize(2*n+1,0);
- tp.resize(2*n+1,2);
- cin >> a_sz;
- for(int i=0;i<a_sz;i++){
- int tmp;
- cin >> tmp;
- tp[tmp]=0;
- as.push_back(tmp);
- }
- cin >> b_sz;
- for(int i=0;i<b_sz;i++){
- int tmp;
- cin >> tmp;
- tp[tmp]=1;
- bs.push_back(tmp);
- }
- rec(0,0,0);
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement