cf1072B. Curiosity Has No Limits(枚举)
题意
给出两个序列\(a, b\),求出一个序列\(t\),满足
\]
\]
同时,\(0 \leqslant a_i, b_i, t_i \leqslant 3\)
Sol
打比赛的时候想到了拆位,从此走上不归路。。。
显然,当最后一位确定了之后,其他的数也都跟着确定了,。。
所以暴力枚举每个位置上是哪个数就行。。
/*
*/
#include<bits/stdc++.h>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long
#define LL long long
#define rg register
#define pt(x) printf("%d ", x);
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
using namespace std;
const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7, B = 1;
const double eps = 1e-9;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N, a[MAXN], b[MAXN], f[MAXN];
void solve(int val) {
f[N] = val;
for(int i = N - 1; i >= 1; i--) {
bool flag = 0;
for(int j = 0; j <= 3; j++) {
int nx = f[i + 1]; f[i] = j;
if((a[i] == (f[i] | f[i + 1])) && (b[i] == (f[i] & f[i + 1]))) {flag = 1; break;}
}
if(!flag) return ;
}
puts("YES");
for(int i = 1; i <= N; i++) printf("%d ", f[i]);
exit(0);
}
main() {
//Fin(a);
N = read();
for(int i = 1; i <= N - 1; i++) a[i] = read();
for(int i = 1; i <= N - 1; i++) b[i] = read();
solve(0); solve(1); solve(2); solve(3);
puts("NO");
return 0;
}
/*
*/
cf1072B. Curiosity Has No Limits(枚举)的更多相关文章
- CF1072B Curiosity Has No Limits
思路: 对于序列t,只要第一个数确定了,后续的数也随之确定了.枚举四种情况即可.实现: #include <iostream> #include <vector> using ...
- CodeForce 517 Div 2. B Curiosity Has No Limits
http://codeforces.com/contest/1072/problem/B B. Curiosity Has No Limits time limit per test 1 second ...
- CF-1027-B. Curiosity Has No Limits
CF-1027-B. Curiosity Has No Limits http://codeforces.com/contest/1072/problem/B 题意: 给定两组序列a,b,长度为n-1 ...
- Technocup 2019 - Elimination Round 2
http://codeforces.com/contest/1031 (如果感觉一道题对于自己是有难度的,不要后退,懂0%的时候敲一遍,边敲边想,懂30%的时候敲一遍,边敲边想,懂60%的时候敲一遍, ...
- Codeforces 1072 - A/B/C/D - (Done)
链接:http://codeforces.com/contest/1072/ A - Golden Plate - [计算题] #include<bits/stdc++.h> using ...
- Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++ ...
- HDU 1017 A Mathematical Curiosity(枚举)
题目链接 Problem Description Given two integers n and m, count the number of pairs of integers (a,b) suc ...
- HDU 1017 A Mathematical Curiosity (枚举水题)
Problem Description Given two integers n and m, count the number of pairs of integers (a,b) such tha ...
- 如何解决编译linux内核(解决声卡问题),遭遇fatal error: linux/limits.h: 没有那个文件或目录
最近帮一位上海的朋友搞一块小板,在ubuntu15.04 vivid上已经加载了对应了.ko驱动包 但关键是系统根本就枚举不到该声卡ALC5640,试了OpenSUSE也是一样的结果,看来是内核漏加载 ...
随机推荐
- eclipse创建springmvc项目
一.在eclipse中创建maven-archetype-webapp项目: 1.新建项目选择maven项目 2.默认,下一步 3.选择maven-archetype-webapp,其他保持默认即可 ...
- sqlserver 临时表,多用户同时访问冲突吗?
当然不会冲突,一个井号的临时表(本地临时表),在数据库中物理表名并非你看到的,而是系统会为你的临时表生成一个唯一的表名,所以其它用户使用和建同样的表不会发生冲突.
- springboot整合activemq加入会签,自动重发机制,持久化
消费者客户端成功接收一条消息的标志是:这条消息被签收. 消费者客户端成功接收一条消息一般包括三个阶段: 1.消费者接收消息,也即从MessageConsumer的receive方法返 ...
- POJ_1703 Find them, Catch them 【并查集】
一.题面 POJ1703 二.分析 需要将并查集与矢量法则相结合.par数组用以记录父节点,rank用以记录与父节点的关系.如题意,有两种关系,设定0是属于同一个帮派,1表示不属于同一个帮派. 运用并 ...
- 文件对象FSO应用 文件对象FSO应用
FileSystemObject对象被用来访问服务器上的文件系统.这个对象能够处理文件.文件夹和目录路径.用它来检索文件系统信息也是可能的. 下面的代码创建了一个文本文件,并写入了一些文本: dim ...
- PHP验证身份信息
$code = 'code'; $patt = "/^[1-9]\d{5}(19|20)\d{2}((0[1-9])|(10|11|12))([012](\d|(30|31)))\d{3}[ ...
- 实现Java程序跨平台运行十二个注意事项
[转自] http://blog.chinaunix.net/uid-20550186-id-1927257.html 使用Java语言编写应用程序最大的优点在于"一次编译,处处运行&quo ...
- 对avalonjs的研究
<!DOCTYPE html> <html> <head> <title>第一个avalon项目</title> <meta char ...
- pymongodb的使用和一个腾讯招聘爬取的案例
一.在python3中操作mongodb 1.连接条件 安装好pymongo库 启动mongodb的服务端(如果是前台启动后就不关闭窗口,窗口关闭后服务端也会跟着关闭) 3.使用 import pym ...
- PIE SDK波谱运算
1.算法功能简介 波谱运算(Spectral Math)是一种灵活的波谱处理工具,可以用数学表达式或IDL程序对波谱曲线(以及选择的多波段图像)进行处理.波谱曲线可以来自一幅多波段图像的Z剖面.波谱库 ...