Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6. typedef long double ld;
  7.  
  8. //#define int long long
  9. int n;
  10. int ans=0;
  11. int a_sz;
  12. int b_sz;
  13. int c_sz;
  14. int mp[2][35];
  15. vector<int> as;
  16. vector<int> bs;
  17. vector<int> tp;
  18. vector<int> used;
  19.  
  20. void rec(int pos,int last_up,int last_down){
  21. if(pos==n){
  22. ans++;
  23. for(int i=0;i<2;i++){
  24. for(int j=0;j<n;j++){
  25. cout << mp[i][j] << " ";
  26. }
  27. cout << endl;
  28. }
  29. cout << endl;
  30. return;
  31. }
  32. for(int i=last_up+1;i<=2*n;i++){
  33. if(used[i]) continue;
  34. if(tp[i]==1) continue;
  35. for(int j=max(i+1,last_down+1);j<=2*n;j++){
  36. if(used[j]) continue;
  37. if(tp[j]==0) continue;
  38. used[i]=1;
  39. used[j]=1;
  40. mp[0][pos]=i;
  41. mp[1][pos]=j;
  42. rec(pos+1,i,j);
  43. used[i]=0;
  44. used[j]=0;
  45. }
  46. }
  47. }
  48.  
  49. signed main(){
  50. ios_base::sync_with_stdio(false);
  51. cin.tie(0);
  52.  
  53. cin >> n;
  54. used.resize(2*n+1,0);
  55. tp.resize(2*n+1,2);
  56. cin >> a_sz;
  57.  
  58. for(int i=0;i<a_sz;i++){
  59. int tmp;
  60. cin >> tmp;
  61. tp[tmp]=0;
  62. as.push_back(tmp);
  63. }
  64. cin >> b_sz;
  65. for(int i=0;i<b_sz;i++){
  66. int tmp;
  67. cin >> tmp;
  68. tp[tmp]=1;
  69. bs.push_back(tmp);
  70. }
  71. rec(0,0,0);
  72. cout << ans << endl;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement