Codeforces Round #265 (Div. 2) C - No to Palindromes!
2014-11-01 15:50
459 查看
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; const int N = 1005; char c ; int main() { int n, p; while(~scanf("%d%d", &n, &p)) { scanf("%s", c); int pos = n - 1; c[pos]++; while( pos >= 0 && pos < n ) { if( c[pos] >= 'a' + p) { c[pos] = 'a'; c[--pos] ++; } else if( c[pos] == c[pos-1] && pos >= 0 || c[pos] == c[pos - 2] && pos >= 1 ) { c[pos]++; } else { pos++; } } if(pos > 0) printf("%s\n", c); else printf("NO\n"); } return 0; }
相关文章推荐
- Codeforces Round #265 (Div. 1) A No to Palindromes!
- Codeforces Round #265 (Div. 2) C. No to Palindromes!
- Codeforces Round #265 (Div. 2) C.No to Palindromes!
- Codeforces Round #265 (Div. 2) C. No to Palindromes! 构造不含回文子串的串
- Codeforces Round #265 (Div. 2) C. No to Palindromes!
- Codeforces Round #265 (Div. 2) C. No to Palindromes! 构建无回文串子
- Codeforces Round #265 (Div. 2) C. No to Palindromes!(字符串+构造??)
- Codeforces Round #265 (Div. 2) C. No to Palindromes! 构造不含回文子串的串
- Codeforces Round #265 (Div. 2)-C. No to Palindromes!
- Codeforces Round #265 (Div. 2)D(判断立方体)
- Codeforces Round #265 (Div. 2) B. Inbox (100500)(模拟)
- Codeforces Round #265 (Div. 2) E
- Codeforces Round #265 (Div. 2) C 暴力+ 找规律+ 贪心
- Codeforces Round #265 (Div. 2)
- Codeforces Round #265 (Div. 2)D. Restore Cube 暴力
- Codeforces Round #265 (div2) A. inc ARG
- Codeforces Round #265 (Div. 2)
- Codeforces Round #265 (Div. 2) 465A. inc ARG(数学题)
- Codeforces Round #265 (Div. 2)
- Codeforces Round #265 (Div. 1) A