Advertisement
kostes

Untitled

Oct 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define FI(_n) for(int i = 0;i<(_n);i++)
  3. #define FJ(_n) for(int j = 0;j<(_n);j++)
  4. using namespace std;
  5. typedef long long ll;
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. // ifstream cin("input.txt");
  10. // ofstream cout("output.txt");
  11. cin.tie(0);cout.tie(0);
  12.  
  13. int n;
  14. cin>>n;
  15. vector<int> a(n-1),b(n-1);
  16. FI(n-1) cin>>a[i];
  17. FI(n-1) cin>>b[i];
  18. vector<int> t1(n),t2(n);
  19. FI(n-1)
  20. {
  21. if(i==0)
  22. {
  23. t1[i] = b[i];
  24. t1[i+1] = b[i];
  25. t2[i] = b[i];
  26. t2[i+1] = b[i];
  27. t1[i]|=(a[i]&1);
  28. t1[i]|=(a[i]&1<<1);
  29. t2[i+1]|=(a[i]&1);
  30. t2[i+1]|=(a[i]&1<<1);
  31. continue;
  32. }
  33. //cerr<<t1[i]<<" "<<t2[i]<<"\n";
  34. t1[i+1] = b[i];
  35. t1[i+1]|=((t1[i]&1)^(a[i]&1));
  36. t1[i+1]|=((t1[i]&1<<1)^(a[i]&1<<1));
  37.  
  38. t2[i+1] = b[i];
  39. t2[i+1]|=((t2[i]&1)^(a[i]&1));
  40. t2[i+1]|=((t2[i]&1<<1)^(a[i]&1<<1));
  41. }
  42. bool go1 = 1, go2 = 1;
  43. for(int i=0;i<n-1;i++)
  44. {
  45. if(((t1[i]&t1[i+1])!=b[i])||((t1[i]|t1[i+1])!=a[i]))
  46. {
  47. go1 = 0;
  48. break;
  49. }
  50. }
  51. for(int i=0;i<n-1;i++)
  52. {
  53. if(((t2[i]&t2[i+1])!=b[i])||((t2[i]|t2[i+1])!=a[i]))
  54. {
  55. go2 = 0;
  56. break;
  57. }
  58. }
  59. if(go1)
  60. {
  61. cout<<"YES\n";
  62. FI(n) cout<<t1[i]<<" ";
  63. return 0;
  64. }
  65. if(go2)
  66. {
  67. cout<<"YES\n";
  68. FI(n) cout<<t2[i]<<" ";
  69. return 0;
  70. }
  71. cout<<"NO";
  72.  
  73.  
  74. // cin.close();
  75. // cout.close();
  76. return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement