Codeforces Round #442 (Div. 2) A Alex and broken contest

A. Alex and broken contest
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.

But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name.

It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita".

Names are case sensitive.

Input

The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem.

Output

Print "YES", if problem is from this contest, and "NO" otherwise.

Examples
input
Alex_and_broken_contest
output
NO
input
NikitaAndString
output
YES
input
Danil_and_Olya
output
NO


题意 给出四个字符串 求输入的字符串s中 如果有且只有一个字符串包含在s中 那么就输出Yes 反之输出No

用很蠢的方法判断一下

#include 
#include 
#include 
#include 
#include 
using namespace std;

int main()
{
	char str[150];
	int D = 0, O = 0, S = 0, A = 0, N = 0;
	scanf("%s", str);
	int l = strlen(str);
	str[l] = str[l + 1] = str[l + 2] = str[l + 3] = str[l + 4] = '0';
	for (int i = 0; i < l; i ++) {
		if (str[i] == 'A' && str[i + 1] == 'n' && str[i + 2] == 'n') {
			A ++;
		}
		if (str[i] == 'O' && str[i + 1] == 'l' && str[i + 2] == 'y' && str[i + 3] == 'a') {
			O ++;
		}
		if (str[i] == 'D' && str[i + 1] == 'a' && str[i + 2] == 'n' && str[i + 3] == 'i' && str[i + 4] == 'l') {
			D ++;
		}
		if (str[i] == 'S' && str[i + 1] == 'l' && str[i + 2] == 'a' && str[i + 3] == 'v' && str[i + 4] == 'a') {
			S ++;
		}
		if (str[i] == 'N' && str[i + 1] == 'i' && str[i + 2] == 'k' && str[i + 3] == 'i' && str[i + 4] == 't' && str[i + 5] == 'a') {
			N ++;
		}
	}
	if (A + O + D + S + N == 1) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
}


你可能感兴趣的:(水题,codeforces)