Official
A - UFO襲来 / UFO Invasion Editorial by en_translator
If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.
In this problem, it is sufficient to input \(S\) as a string and check if the \(1\)-st through the \(4\)-th, the \(2\)-nd to the \(5\)-th, … are ZONe
.
Some language may have features that make solving easier.
Sample Code (C++)
#include <iostream>
#include <string>
using namespace std;
int main(){
string S;
cin >> S;
int ans = 0;
if(S.substr(0, 4) == "ZONe") ans++;
if(S.substr(1, 4) == "ZONe") ans++;
if(S.substr(2, 4) == "ZONe") ans++;
if(S.substr(3, 4) == "ZONe") ans++;
if(S.substr(4, 4) == "ZONe") ans++;
if(S.substr(5, 4) == "ZONe") ans++;
if(S.substr(6, 4) == "ZONe") ans++;
if(S.substr(7, 4) == "ZONe") ans++;
if(S.substr(8, 4) == "ZONe") ans++;
cout << ans << endl;
}
Sample Code (Python)
print(input().count("ZONe"))
posted:
last update: