You are given a string S. Each character of S is uppercase or lowercase English letter.…
- User
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
- The initial character of S is an uppercase
A. - There is exactly one occurrence of
Cbetween the third character from the beginning and the second to last character (inclusive). - All letters except the
AandCmentioned above are lowercase.
Constraints
- 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
- Each character of S is uppercase or lowercase English letter. Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print
AC; otherwise, printWA.Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
- The initial character of S is an uppercase
Assistant
pythonS = input().strip() # Check condition 1: first character is 'A' if len(S) < 1 or S[0] != 'A': print("WA") exit() count_c = 0 c_pos = -1 # Check condition 2: exactly one 'C' in positions 2 to len(S)-2 inclusive allowed_start = 2 allowed_end = len(S) - 2 for i in range(allowed_start, allowed_end + 1): if i >= len(S): continue # handle cases where allowed_end is beyond the string length (unlikely due to constraints) if S[i] == 'C': count_c += 1 c_pos = i if count_c != 1: print("WA") exit() # Check condition 3: all other characters are lowercase for i in range(len(S)): if i == 0 or i == c_pos: continue if not S[i].islower(): print("WA") exit() print("AC")
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.