CSES - Putka Open 2015 – finaali - Results
Submission details
Task:Sanat
Sender:Henrik Lievonen
Submission time:2015-12-20 17:11:21 +0200
Language:C++
Status:READY
Result:46
Feedback
groupverdictscore
#1ACCEPTED46
Test results
testverdicttimescore
#1ACCEPTED0.27 s46details

Code

// F

#include <iostream>
#include <string>

using namespace std;

bool iswovel(const char c) {
  switch (c) {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
    case 'y':
      return true;
    default:
      return false;
  }
}
bool isconsonant(const char c) {
  return !iswovel(c);
}
bool endswith(const string str, const string fix) {
  if (fix.size() > str.size())
    return false;
  return str.substr(str.size()-fix.size()) == fix;
}
bool contains(const string str, const string s) {
  return str.find(s) != string::npos;
}
bool startswithtwoconsonants(const string str) {
  return isconsonant(str[0]) && isconsonant(str[1]);
}
bool endswithtwoconsonants(const string str) {
  return isconsonant(str[str.size()-1]) && isconsonant(str[str.size()-2]);
}
bool containstreeconcequentwovels(const string str) {
  int a = 0;
  for (char c : str) {
    if (iswovel(c)) {
      a++;
      if (a >= 3)
	return true;
    } else {
      a = 0;
    }
  }
  return false;
}
int countwovels(const string str) {
  int a = 0;
  for (char c : str)
    if (iswovel(c))
      a++;
  return a;
}
int countconsonants(const string str) {
  int a = 0;
  for (char c : str)
    if (isconsonant(c))
      a++;
  return a;
}

bool testaa(const string sana) {
  if (startswithtwoconsonants(sana))
    return false;
  if (endswithtwoconsonants(sana))
    return false;
  if (endswith(sana, "nen"))
    return true;
  if (endswith(sana, "ni"))
    return true;
  if (contains(sana, "ph"))
    return false;
  if (contains(sana, "ch"))
    return false;
  if (contains(sana, "f"))
    return false;
  if (contains(sana, "z"))
    return false;
  if (contains(sana, "q"))
    return false;
  if (contains(sana, "x"))
    return false;
  if (contains(sana, "c"))
    return false;
  if (contains(sana, "w"))
    return false;
  if (contains(sana, "b"))
    return false;
  if (contains(sana, "ck"))
    return false;
  if (contains(sana, "g") && !contains(sana, "ng"))
    return false;
  if (containstreeconcequentwovels(sana))
    return false;
  if (countconsonants(sana) > countwovels(sana))
    return false;
  return true;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (testaa(s))
      cout<<"10-4\n";
    else
      cout<<"QAQ\n";
  }
}

Test details

Test 1

Verdict: ACCEPTED

input
95000
pursua
zoomata
mantelilastu
jamming
...

correct output
10-4
10-4
10-4
QAQ
QAQ
...

user output
10-4
QAQ
QAQ
QAQ
QAQ
...