思路:

对于序列t,只要第一个数确定了,后续的数也随之确定了。枚举四种情况即可。
实现:

 #include <iostream>
#include <vector> using namespace std;
int a[], b[];
int get(int t, int a, int b)
{
int ans = , cnt = ;
while (t || a || b)
{
int x = t & , y = a & , z = b & ;
if (x == && y == && z == ) ans |= << cnt;
else if (x == && y == && z == ) ans |= << cnt;
else if (x == && y == && z == ) return -;
else if (x == && y == && z == ) return -;
else if (x == && y == && z == ) return -;
else if (x == && y == && z == ) return -;
t >>= ;
a >>= ;
b >>= ;
cnt++;
}
return ans;
}
int main()
{
int n;
while (cin >> n)
{
for (int i = ; i < n - ; i++) cin >> a[i];
for (int i = ; i < n - ; i++) cin >> b[i];
bool ok = false;
for (int k = ; k < ; k++)
{
if (ok) break;
vector<int> v;
v.push_back(k);
bool flg = true;
for (int i = ; i < n - ; i++)
{
int tmp = get(v.back(), a[i], b[i]);
if (tmp == -) { flg = false; break; }
v.push_back(tmp);
}
if (flg)
{
cout << "YES" << endl;
for (auto it: v) cout << it << " ";
cout << endl;
ok = true;
}
}
if (!ok) cout << "NO" << endl;
}
return ;
}

最新文章

  1. 设计winform自带动态加载工具按钮和实现热键响应
  2. zookeeper 的多线程和单线程库使用对比
  3. Daily Scrum 12.1
  4. 随便谈谈alphago与人机大战
  5. HDU 5166(缺失数查找输出)
  6. 读取文件内容返回List&lt;String&gt;类型
  7. COJ 0560 4015划分数
  8. IIS怎么设置本地域名解析(本地域名测试配置)
  9. Repository 设计模式介绍(转)
  10. 有关HTTP的粗读
  11. C语言学生管理系统(原版本)(自编)
  12. ●CodeForces 429D Trick_Function
  13. ElasticSearch 2 (30) - 信息聚合系列之条形图
  14. [BZOJ4484][JSOI2015]最小表示[拓扑排序+bitset]
  15. Am335x 下GPIO控制实例-驱动程序(转)
  16. #include &lt;sys/epoll.h&gt; epoll - I/O event notification facility 服务器端 epoll(7) - Linux manual page http://www.man7.org/linux/man-pages/man7/epoll.7.html
  17. CentOS 添加常用 yum 源(转)
  18. 利用SQLServer查询分析器获取存储过程的返回值,检查测试存储过程
  19. 140726暑期培训.txt
  20. Couldn&#39;t find a tree builder with the features you requested: lxml. Do you need to install a parser library?

热门文章

  1. 出现”/var/lib/mysql/mysql.sock“不存在的解决方法
  2. weex 创建项目坑2
  3. Monkey学习(转载)
  4. $.ajax数据传输成功却执行失败的回调函数
  5. Google浏览器如何加载本地文件
  6. 1079 Total Sales of Supply Chain (25 分)
  7. c# 中的 protected internal 如何在 vc.net 中实现
  8. cf786C(xjb)
  9. element走过的坑
  10. 面向对象-mixin设计模式的应用(多继承应用场景)