标签:using name ons length names turn str check nbsp
题意:https://nanti.jisuanke.com/t/31450
题解:题目很长的模拟,有点uva的感觉
分成四步
part1 16进制转为二进制string 用bitset的to_string()
part2 parity check 校对,将处理结果pushback到另一个string
part3 建字典树,用形如线段树的数组存
part4 遍历字典树
1A 233
#include<bitset> #include <cstdio> #include <cmath> #include <complex> #include <algorithm> #include <iostream> #include<string.h> #define rep(i,t,n) for(int i =(t);i<=(n);++i) #define per(i,n,t) for(int i =(n);i>=(t);--i) #define mmm(a,b) memset(a,b,sizeof(a)) typedef long long ll; using namespace std; const int maxn = 8e5; int tot = 0; const int MAXN = 10000009; bitset<maxn>bi; bitset<4>buff[200000+5]; char s[200000 + 5]; char tree[1024 * 4]; int n; string ss; string cd; int main() { int t; cin >> t; while (t--) { ss.clear(); cd.clear(); mmm(tree, 0); int n,m; cin >> m >> n; rep(i, 1, n) { int x; char op[11]; cin >> x >> op; int len = strlen(op); int now = 1; rep(j, 0, len - 1) { if (op[j] == ‘1‘) now = now * 2 + 1; else now = now * 2; } tree[now] = (char)x; } scanf("%s", s); int len = strlen(s); int tot = 0; rep(i, 0, len - 1) { if (isdigit(s[i]))buff[tot++] = s[i] - 0; else if (s[i] >= ‘a‘&&s[i] <= ‘z‘)buff[tot++] = s[i] - ‘a‘ + 10; else buff[tot++] = s[i] - ‘A‘ + 10; } //rep(i, 0, tot - 1)cout << buff[i] ;cout << endl; rep(i, 0, tot - 1) ss += buff[i].to_string(); len = ss.length(); int cnt = 0; rep(i, 0, len-1) { if (i % 9 == 8) { if (cnt % 2 == 0 && ss[i] == ‘1‘|| cnt % 2 == 1 && ss[i] == ‘0‘) { string temp = ss.substr(i - 8, 8); cd += temp; } } if (i % 9 == 0)cnt = 0; if (ss[i] == ‘1‘)cnt++; } len = cd.length(); rep(i, 0, len - 1) { int now = 1; while (now == 1 || !tree[now]) { if (cd[i] == ‘1‘) now = now * 2 + 1; else now = now * 2; i++; } printf("%c", tree[now]); m--; if (m == 0)break; i--; } cout << endl; } cin >> t; return 0; } /* 2 15 9 32 0100 33 11 100 1011 101 0110 104 1010 108 00 111 100 114 0111 119 0101 A6Fd021171c562Fde1 8 3 49 0001 50 01001 51 011 14DB24722698 */
ACM-ICPC 2018 沈阳赛区网络预赛 I. Lattice's basics in digital electronics 阅读题加模拟题
标签:using name ons length names turn str check nbsp
原文地址:https://www.cnblogs.com/SuuT/p/9610210.html