ACM-ICPC 2018 沈阳赛区网络预赛 I Lattice's basics in digital electronics(模拟)
https://nanti.jisuanke.com/t/31450
题意
给出一个映射(左为ascll值),然后给出一个16进制的数,要求先将16进制转化为2进制然后每9位判断,若前8位有奇数个1且第9位为0则这个子串取,若前8位有偶数个1且第9 位为1也取。取出的串在映射中进行查找,输出对应ascll值的字符
分析
用map直接模拟,细节需要注意。
#include <bits/stdc++.h>
using namespace std;
#define ms(a, b) memset(a, b, sizeof (a))
typedef long long ll;
const int maxn = 1e5+;
//const int inf = 1e9+7;
map<string, char> dic;
map<string, char> ::iterator it;
char s[];
char data[];
char data01[];
char r_data[];
int HtoD(char x){
if(x>=''&&x<=''){
return x - '';
}else if(x>='A'&&x<='F'){
return x-'A'+;
}else{
return x-'a'+;
}
}
bool check(int x){
int cnt = ;
for(int i = x;i<x+;i++){
if(data01[i]=='') cnt++;
}
if(cnt&){
return data01[x+]=='';
}else{
return data01[x+]=='';
}
}
int main(){
#ifdef LOCAL
freopen("in","r",stdin);
// freopen("out.txt","w",stdout);
#endif // LOCAL
int t;
scanf("%d", &t);
for(int _=;_<t;_++){
int m, n, c;
scanf("%d%d", &m, &n);
dic.clear();
for(int i = ;i<n;i++){
scanf("%d%s", &c, s);
dic[s]=(char)c;
}
scanf("%s", data);
int data_len = strlen(data);
for(int i = ;i<data_len;i++){
int x = HtoD(data[i]);
for(int j = ;j>=;j--){
if(x&(<<j))
data01[*i+-j] = '';
else
data01[*i+-j] = '';
}
}
// for(int i = 0;i<data_len*4;i+=4){
// printf("%c", data01[i]);
// printf("%c", data01[i+1]);
// printf("%c", data01[i+2]);
// printf("%c", data01[i+3]);
// printf(" ");
// }
int r_len = ;
for(int i = ;i<data_len*;i+=){
if(i+<=data_len* && check(i)){
for(int j = i;j<i+;j++){
r_data[r_len++] = data01[j];
// printf("%c", data01[j]);
}
// printf("\n");
}
}
string query = "";
for(int i = ;i<r_len;i++){
query += r_data[i];
it = dic.find(query);
if(it!=dic.end()){
printf("%c", (*it).second);
query = "";
m--;
if(m==) break;
} }
puts("");
}
return ;
}
ACM-ICPC 2018 沈阳赛区网络预赛 I Lattice's basics in digital electronics(模拟)的更多相关文章
- ACM-ICPC 2018 沈阳赛区网络预赛 I. Lattice's basics in digital electronics 阅读题加模拟题
题意:https://nanti.jisuanke.com/t/31450 题解:题目很长的模拟,有点uva的感觉 分成四步 part1 16进制转为二进制string 用bitset的to_stri ...
- ACM-ICPC 2018 沈阳赛区网络预赛 K Supreme Number(规律)
https://nanti.jisuanke.com/t/31452 题意 给出一个n (2 ≤ N ≤ 10100 ),找到最接近且小于n的一个数,这个数需要满足每位上的数字构成的集合的每个非空子集 ...
- ACM-ICPC 2018 沈阳赛区网络预赛-K:Supreme Number
Supreme Number A prime number (or a prime) is a natural number greater than 11 that cannot be formed ...
- ACM-ICPC 2018 沈阳赛区网络预赛-D:Made In Heaven(K短路+A*模板)
Made In Heaven One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. ...
- 图上两点之间的第k最短路径的长度 ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven
131072K One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. Howe ...
- ACM-ICPC 2018 沈阳赛区网络预赛 J树分块
J. Ka Chang Given a rooted tree ( the root is node 11 ) of NN nodes. Initially, each node has zero p ...
- ACM-ICPC 2018 沈阳赛区网络预赛 K. Supreme Number
A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying ...
- ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph
"Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a ...
- Fantastic Graph 2018 沈阳赛区网络预赛 F题
题意: 二分图 有k条边,我们去选择其中的几条 每选中一条那么此条边的u 和 v的度数就+1,最后使得所有点的度数都在[l, r]这个区间内 , 这就相当于 边流入1,流出1,最后使流量平衡 解析: ...
随机推荐
- win10系统的“USB选择性暂停设置”怎么打开
Win10系统自带的“USB选择性暂停设置”功能开启后会帮助我们节省电源,这一项功能对于笔记本来说用处很大.那么怎样才能打开这一功能呢?下面小编就来告诉大家打开“USB选择性暂停设置”功能的方法. 1 ...
- Elixir 分布式平台
概述 分布式平台的核心在于并发,容错. 而 Elixir 的优势正是在于对于并发和容错的处理. 分布式模型 CSP(Communicating Sequential Process) 模型 :: 多个 ...
- Django REST framework框架介绍和基本使用
Django REST framework介绍 Django REST framework是基于Django实现的一个RESTful风格API框架,能够帮助我们快速开发RESTful风格的API. 官 ...
- Django中的信号
信号 Django 提供一个“信号分发器”,允许解耦的应用在框架的其它地方发生操作时会被通知到. 简单来说,信号允许特定的sender通知一组receiver某些操作已经发生. 这在多处代码和同一事件 ...
- spring MVC处理请求过程
spring MVC处理请求过程 首先看一个整体图 简单说下各步骤: handlerMapping handlerMapping将请求映射到处理器,即图中的HandlerExecutionChain. ...
- ESP8266远程OTA升级
https://blog.csdn.net/xh870189248/article/details/80095139 https://www.wandianshenme.com/play/arduin ...
- 在区块链上表白——使用C#将一句话放入比特币的区块链上
最近在看区块链和比特币的知识,顺便简单研究了一下BitCoin的脚本语言,发现OP_RETURN这个命令可以在后面放入自己想说的内容,很多侧链啊,公证之类就是利用了这个特性,可以把一句话,或者一个哈希 ...
- Google第三方网站登录(JavaScript SDK)
官网:https://developers.google.com/identity/sign-in/web/ 一.创建应用 a.去谷歌控制台创建应用 网址:https://accounts.g ...
- 【Swift 2.2】iOS开发笔记(三)
1.UITableView 中调用 UIButton 的 setTitle 会闪 滚动列表时比较明显,解决办法: buttonType 改成 custom 即可,但是这样一来 UIButton 的高亮 ...
- mapreduce map 的个数
在map阶段读取数据前,FileInputFormat会将输入文件分割成split.split的个数决定了map的个数.影响map个数(split个数)的主要因素有: 1) 文件的大小.当块(dfs. ...