Editorial for Bedao Mini Contest 24 - Non Palindrome
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Nếu xâu ~S~ chỉ gồm duy nhất ~1~ chữ cái, đáp án là ~0~.
Nếu xâu ~S~ là xâu đối xứng kết quả bằng ~N-1~.
Ngược lại, đáp án là ~N~.
#include <bits/stdc++.h> using namespace std; int N; string S; int main() { cin >> N >> S; bool Palind = 1, same = 1; for (int i = 0; i < N; ++i) { if (S[i] != S[N - i - 1]) Palind = 0; if (S[i] != S[0]) same = 0; } if(same) { cout << 0; } else if (Palind) { cout << N - 1; } else { cout << N; } return 0; }
Comments