Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define FI(_n) for(int i = 0;i<(_n);i++)
- #define FJ(_n) for(int j = 0;j<(_n);j++)
- using namespace std;
- typedef long long ll;
- int main()
- {
- ios_base::sync_with_stdio(0);
- // ifstream cin("input.txt");
- // ofstream cout("output.txt");
- cin.tie(0);cout.tie(0);
- int n;
- cin>>n;
- vector<int> a(n-1),b(n-1);
- FI(n-1) cin>>a[i];
- FI(n-1) cin>>b[i];
- vector<int> t1(n),t2(n);
- FI(n-1)
- {
- if(i==0)
- {
- t1[i] = b[i];
- t1[i+1] = b[i];
- t2[i] = b[i];
- t2[i+1] = b[i];
- t1[i]|=(a[i]&1);
- t1[i]|=(a[i]&1<<1);
- t2[i+1]|=(a[i]&1);
- t2[i+1]|=(a[i]&1<<1);
- continue;
- }
- //cerr<<t1[i]<<" "<<t2[i]<<"\n";
- t1[i+1] = b[i];
- t1[i+1]|=((t1[i]&1)^(a[i]&1));
- t1[i+1]|=((t1[i]&1<<1)^(a[i]&1<<1));
- t2[i+1] = b[i];
- t2[i+1]|=((t2[i]&1)^(a[i]&1));
- t2[i+1]|=((t2[i]&1<<1)^(a[i]&1<<1));
- }
- bool go1 = 1, go2 = 1;
- for(int i=0;i<n-1;i++)
- {
- if(((t1[i]&t1[i+1])!=b[i])||((t1[i]|t1[i+1])!=a[i]))
- {
- go1 = 0;
- break;
- }
- }
- for(int i=0;i<n-1;i++)
- {
- if(((t2[i]&t2[i+1])!=b[i])||((t2[i]|t2[i+1])!=a[i]))
- {
- go2 = 0;
- break;
- }
- }
- if(go1)
- {
- cout<<"YES\n";
- FI(n) cout<<t1[i]<<" ";
- return 0;
- }
- if(go2)
- {
- cout<<"YES\n";
- FI(n) cout<<t2[i]<<" ";
- return 0;
- }
- cout<<"NO";
- // cin.close();
- // cout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement