题目链接:https://vjudge.net/problem/UVA-213
不知道这题什么鬼,换行不能用cout<<endl;
后面改成printf就AC了
代码如下:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<sstream>
#include<map>
//#define DEBUG
const int maxn = 50;
using namespace std;;
int n, k, m;
int codehead[8][1 << 8];
int readchar();
int readcode();
int readint(int c);
int main() {
#ifdef DEBUG
freopen("Text.txt", "r", stdin);
#endif // DEBUG
cin.tie(0);
cin.sync_with_stdio(false);
while (readcode()) {
/*readcode();
for (int len = 2; len <= 3; len++) {
for (int i = 0; i < 3; i++) {
printf("%c", codehead[len][i]);
}
cout << endl;
}*/
while (1) {
int len = readint(3);
if (len == 0)break;
int v;
while (1) {
v = readint(len);
if (v == ((1 << len) - 1))break;
printf("%c", codehead[len][v]);
}
}
printf("\n");
}
return 0;
}
int readchar() {
int c;
c = getchar();
while (c == '\n' || c == '\r')c = getchar();
return c;
}
int readcode() {
memset(codehead, 0, sizeof(codehead));
codehead[1][0] = readchar();
int i, len;
for (len = 2; len < 8; len++) {
for (i = 0; i < (1 << len) - 1; i++) {
int ch = getchar();
if (ch == EOF)return 0;
if (ch == '\n' || ch == '\r')return 1;
codehead[len][i] = ch;
}
}
return 1;
}
int readint(int c) {
int v = 0;
while (c--) v = 2 * v + readchar() - '0';
return v;
}