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也是一样的结果,看来是内核漏加载 ...
随机推荐
- Python编程笔记二进制、字符编码、数据类型
Python编程笔记二进制.字符编码.数据类型 一.二进制 bin() 在python中可以用bin()内置函数获取一个十进制的数的二进制 计算机容量单位 8bit = 1 bytes 字节,最小的存 ...
- python参数传递:对象的引用
大家都知道在python中,一切皆对象,变量也不再具有类型,变量仅仅是对象的一个引用,我们通常用变量来测类型,通常测得就是被这个变量引用得对象的类型. python采用的是传递对象的引用,为了方便说明 ...
- Struts、Hibernate和Spring的整合
Spring整合Hibernate Spring以其开放性,能与大部分ORM框架良好的整合.这样Spring就能轻松地使用ORM. Spring提供了DAO支持,DA0组件是应用的持久层访问的重要组件 ...
- 4,JavaScript数据类型
学习要点:1.typeof 操作符2.Undefined 类型3.Null 类型4.Boolean 类型5.Number 类型6.String 类型7.Object 类型 ECMAScript 中有 ...
- elasticsearch head 连接不到elasticsearch
配置好head后看到没有正常连接到elasticsearch. 重启后效果:
- 解析图书 XML
Java代码: package com.thinkgem.jeesite.test; import org.dom4j.Attribute; import org.dom4j.Document; im ...
- 在文件夹快速启动cmd或powershell
进入指定目录下的几种方法:一般方法 使用win+R的组合键进入运行窗口运行窗口输入cmd进入命令行,使用 ”cd 文件路径“进入指定的文件夹下.cd 命令的基本操作如下: 任意目录下跳转至当前驱动器的 ...
- String Reduction问题分析
问题描述: Given a string consisting of a,b and c's, we can perform the following operation: Take any two ...
- Selenium WebDriver的简单操作说明
[From] http://blog.csdn.net/xiao190128/article/details/49784121 1.打开一个测试浏览器 对浏览器进行操作首先需要打开一个浏览器,接下来才 ...
- C++ GUI Qt4编程(09)-3.3spreadsheet-toolbar
1. C++ GUI Qt4编程第三章,增加工具栏.状态栏和快捷键. 2. mainwindow.h /**/ #ifndef MAINWINDOW_H #define MAINWINDOW_H #i ...