Official

B - uNrEaDaBlE sTrInG Editorial by en_translator


Let us check if the conditions described in the problem statement is satisfied one by one. In many language, arrays are \(0\)-indexed, so we have to be careful of the correspondence of the parity described in the problem statement and the parity of indices.

Sample Code (C++)

#include <bits/stdc++.h>
using namespace std;

int main(){
	string s;
	cin >> s;
	int len=s.length();
	bool is_unreadable=true;
	for(int i=0;i<len;i++){
		if(i%2==0){
			if(!islower(s[i]))is_unreadable=false;
		}else{
			if(!isupper(s[i]))is_unreadable=false;
		}
	}
	if(is_unreadable)cout << "Yes";
	else cout << "No";
}

Sample Code (python)

S = input()
is_unreadable = all([c.islower() if i%2==0 else c.isupper() for i,c in enumerate(S)])
if is_unreadable:
	print("Yes")
else:
	print("No")

posted:
last update: