Codeforces Round #442 A Alex and Broken Contest "string/constant array/string class"

Source: Internet
Author: User

A. Alex and Broken contestTime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

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

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

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

Names is 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.

Examplesinput
Alex_and_broken_contest
Output
NO
Input
Nikitaandstring
Output
YES
Input
Danil_and_olya
Output
NO


"Test Instructions": Give the string, ask whether to find out the 5 name of one of the first occurrence, repeated the name is not.
"Analysis": the magic of a constant character array, note the number of statistics after the discovery of a name. Mark the person who satisfies the condition.
"Code":
#include <bits/stdc++.h>using namespacestd;intFunConstSTD::string& STR,ConstSTD::string&sub) {        intnum =0; size_t Len=sub.length (); if(len = =0) len=1;//deal with a substring call         for(size_t i=0; (I=str.find (sub,i))! = std::string:: NPOs; num++, i+=Len); returnnum; }intFunstringSstringT) {//    intres =0;  for(inti =0; I < (int) S.size (); i++) {        if(S.substr (I, t.size ()) = = T) res++; }    returnRes;}intMain () {strings[5] = {"Danil","Olya","Slava","Ann","Nikita"}; stringT; CIN>>T; intCnt=0;  for(intI=0;i<5; i++) {CNT+=Fun (T,s[i]); }    if(cnt==1) cout<<"YES"; Elsecout<<"NO"; return 0;}
strstr function

#include <bits/stdc++.h>using namespacestd;intMain () {strings; stringA[] = {"Danil","Olya","Slava","Ann","Nikita"}; CIN>>s; intCNT =0;  for(stringi:a) {size_t pos= S.find (I,0);  while(POS! =string:: NPOs) {CNT++; POS= S.find (i, POS +1); }} printf ("%s\n", cnt = =1?"Yes":"No"); return 0;}
Find function

Codeforces Round #442 A Alex and Broken Contest "string/constant array/string class"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.