Official

A - Job Interview 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.
Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in “AtCoder Beginners Selection” (https://atcoder.jp/contests/abs).
「競プロ典型 90 問」(Typical 90 Problems of Competitive Programming) (https://atcoder.jp/contests/typical90) is a collection of typical 90 competitive programming problems; unfortunately, currently the problem statements are all Japanese.
「C++入門 AtCoder Programming Guide for beginners (APG4b)」(https://atcoder.jp/contests/APG4b) is a C++ tutorial for competitive programmers. Sadly, this is only in Japanese too.


We prepare two variables \(f1\) and \(f2\) that stores whether the two conditions are satisfied, and print Yes if these are both \(true\) and No otherwise. (This way, the two conditions can be treated independently.)

The first condition, “at least one interviewer’s evaluation is Good,” can be checked by initializing \(f1\) with \(false\), inspect each character, and set \(f1\) to \(true\) if that character is o. In C++, it can be written as follows:

bool f1 = false;
for(int i=0;i<N;i++){
	if(S[i]=='o')f1 = true;
}

The second condition, “no interviewer’s evaluation is Poor,” can be checked by initializing \(f2\) with \(true\), inspect each character , and set \(f2\) to \(false\) if that character is x. In C++, it can be written as follows:

bool f2 = true;
for(int i=0;i<N;i++){
	if(S[i]=='x')f2 = false;
}

Combining the codes so far and printing the result based on \(f1\) and \(f2\), your code will be accepted.

Sample code (C++)

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

int main() {
    
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	bool f1 = false;
	for(int i=0;i<N;i++){
		if(S[i]=='o')f1 = true;
	}
	
	bool f2 = true;
	for(int i=0;i<N;i++){
		if(S[i]=='x')f2 = false;
	}
	
	if(f1&&f2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

posted:
last update: