#include <stdio.h> char buf[10001]; int main(){ int t; char *p, ch; scanf("%d\n", &t); while(t--){ buf[0] = getchar(); p = buf + 1; while((ch = getchar()) != ‘\n‘){ if(ch - 1 == *(p - 1) || ch - 2 == *(p - 1)) --p; else *p++ = ch; } printf(p == buf? "Yes\n": "No\n"); } return 0; }
原文:http://blog.csdn.net/chang_mu/article/details/20989635