Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <cstdio>
- #include <vector>
- using namespace std;
- int n;
- vector<int> a;
- vector<int> b;
- vector<int> dp[4];
- int32_t main(){
- cin >> n;
- for(int i = 0; i < 4; i++)dp[i].resize(n, -1);
- a.resize(n-1);
- b.resize(n-1);
- for(int i = 0; i < n-1; i++)cin >> a[i];
- for(int i = 0; i < n-1; i++)cin >> b[i];
- for(int i = 1; i < n; i++){
- int ae = a[i-1];
- int be = b[i-1];
- cout << ae << " - " << be << endl;
- for(int j = 0; j < 4; j++){
- for(int k = 0; k < 4; k++){
- if(ae == (j|k) && be == (j&k)){
- if((dp[i-1][k] != -1) || (i == 1)){
- cout << "SET DP " << i << " " << k << endl;
- dp[i][j] = k;
- }
- }
- }
- }
- }
- for(int i = 0; i < 4; i++){
- if(dp[n-1][i] != -1){
- cout<<"Yes"<<endl;
- return 0;
- }
- }
- cout << "No"<< endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement