文章
68
粉丝
691
获赞
26
访问
577.5k
int main() {
string t;
while (cin >> t) {
int i = 0, len = t.size(), cnt = 1, sign = 1;
for (int i = 0; i < len; i++)
if (t[i] != '#')
t[i] = 'a';//只区分叶子和非叶子
while (i < len) {
if (i == 0)cnt = 1;
string t1 = t.substr(i, cnt), t2 = t1;
reverse(t1.begin(), t1.end());
if (t1 != t2) {
sign = 0; break;
}
i += cnt; cnt = 0;
for (int i = 0; i < t1.size(); i++)
if (t1[i] != '#')cnt++;
cnt *= 2;
}
if (sign)cout << "YES" << endl;
else cout << "NO" << endl;
}
}
登录后发布评论
暂无评论,来抢沙发