B - Tires Editorial by en_translator

This problem is akin to ABC215-A in that it requires receiving a string and dividing into cases. So we will try solving this problem with a similar code.
The output for this problem is determined by the tail of the input string. Specifically, we can get accepted by outputting er if the last character is r, or ist if it is t. Therefore, our objective this time is to divide into cases depending on the last character of the input string. The way depends on languages. For example, if you are using C++, the following code will be accepted.


using namespace std;

int main(){
  string s;
  cin >> s;
  if(s[s.size()-1]=='r'){cout << "er\n";}
  else{cout << "ist\n";}
  return 0;

Such technique of dividing into cases by only some portion of a string simplifies implementations in competitive programming.

last update: