【ACM-ICPC 2018 沈阳赛区网络预赛 I】Lattice's basics in digital electronics
【链接】 我是链接,点我呀:)
【题意】
【题解】
每个单词的前缀都不同。
不能更明示了...
裸的字典树。
模拟一下。输出一下就ojbk了。
【代码】
#include <bits/stdc++.h>
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define lson l,mid,rt<<1
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define rson mid+1,r,rt<<1|1
using namespace std;
const double pi = acos(-1);
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};
const int NN = 10000;
const int SI = 10;
const int N = 2e5;
int ch[NN+10][2],flag[NN+10];
int tot,m,n;
char si[SI+10];
char s[N+10];
int result[N*4+10],cur;
void ins(int ci){
int len = strlen(si);
int now = 1;
for (int i = 0;i < len;i++){
if (ch[now][si[i]-'0']==0){
ch[now][si[i]-'0'] = ++tot;
}
now = ch[now][si[i]-'0'];
}
flag[now] = ci;
}
void cl(char key){
cur++;
int num = 0;
if (key>='a' && key<='z'){
key = key-'a'+'A';
}
if (key>='A' && key<='Z'){
num+=key-'A'+10;
}else num = key-'0';
for (int i = cur+3;i>=cur;i--){
result[i] = num&1;
num/=2;
}
cur = cur+3;
}
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
int T;
cin >> T;
while (T--){
memset(ch,0,sizeof ch);
memset(flag,255,sizeof flag);
tot = 1;
cin >> m >> n;
for (int i = 1;i <= n;i++){
int ci;
cin >> ci >> si;
ins(ci);
}
cin >> s;
int len = strlen(s);
cur = 0;
for (int i = 0;i < len;i++) cl(s[i]);
int now = 1;
for (int i = 1;i <= cur;){
if (i+8>cur) break;
int cnt = 0;
for (int j = i;j <= i+7;j++)
if (result[j]==1) cnt++;
int odd = result[i+8];
odd=1-odd;
if ((cnt&1)==(odd&1)){
for (int j = 1;j <= 8;j++){
result[now+j-1]=result[i+j-1];
}
now = now + 8;
}
i = i+9;
}
int index = 1;
for (int i = 1;i <= m;i++){
int now = 1;
for (int j = index;;j++){
now = ch[now][result[j]];
if (flag[now]!=-1) {
index = j+1;
char key = flag[now];
cout<<key;
break;
}
}
}
cout<<endl;
}
return 0;
}
【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 题意 给出一个映射(左为ascll值),然后给出一个16进制的数,要求先将16进制转化为2进制然后每9位判断,若前8位有奇数个1且 ...
- 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,最后使流量平衡 解析: ...
随机推荐
- 怎样安装g++/gdb
该文的word文档附在文后! 链接:http://pan.baidu.com/s/1bnFcMHDpassword:z7zk
- HDU1846(巴什博奕)
Brave Game Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- Oracle学习(十二):存储过程/存储函数
1.知识点 --第一个存储过程 /* 打印Hello World create [or replace] PROCEDURE 过程名(參数列表) AS PLSQL子程序体: 调用存储过程: 1. ex ...
- LeetCode OJ 之 Delete Node in a Linked List (删除链表中的结点)
题目: Write a function to delete a node (except the tail) in a singly linked list, given only access t ...
- etcd创建集群并增加节点
下载安装 从这下载https://github.com/coreos/etcd/releases/download/v3.3.2/etcd-v3.3.2-linux-amd64.tar.gz tar ...
- B - Even Odds
Problem description Being a nonconformist, Volodya is displeased with the current state of things, p ...
- VS2005常用的快捷键分享
VS2005代码编辑器的展开和折叠代码确实很方便和实用.以下是展开代码和折叠代码所用到的快捷键,很常用: Ctrl + M + O: 折叠所有方法 Ctrl + M + M: 折叠或者展开当前方法 C ...
- Django mysql 改用pymysql 驱动
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', #数据库引擎 'NAME': 'test', #数据库名 'USER' ...
- Visual Studio 编辑代码量大的文件时分屏技巧
- CUDA 编程实例:计算点云法线
程序参考文章:http://blog.csdn.net/gamesdev/article/details/17535755 程序优化2 简介:CUDA ,MPI,Hadoop都是并行运算的工具.CU ...