Cipher Message
.
.
把字符串相邻相同的字符去掉,直至没法再去除为止,暴力模拟就好了
.
.
#include <cstdio>
#include <cstring>
char a[200010];
int nextt[200010], pre[200010];
int main()
{
scanf("%s", a);
int n = strlen(a);
int first = 0;
for (int i = 0; i < n; i++)
{
nextt[i] = i + 1; pre[i + 1] = i;
}
for (int i = first; nextt[i] < n && i < n; i = nextt[i])
{
while (a[i] == a[nextt[i]])
{
if (nextt[i] >= n || i >= n) break;
int q = pre[i];
if (i == first)
{
first = nextt[nextt[i]];
i = first;
continue;
}
else
{
nextt[pre[i]] = nextt[nextt[i]];
pre[nextt[nextt[i]]] = pre[i];
}
i = q;
}
}
for (int i = first; i < n; i = nextt[i])
{
printf("%c", a[i]);
}
printf("\n");
}