Loser_'s blog

By Loser_, history, 4 years ago, In English

1111A - Superhero Transformation I have tried map for tracking either a char is vowel or consonant.And then comparing both the map's element, I may have my expected solution.But implementing map it came to my mind that map is a sorted container.So I google it and from stackoverflow I found this articlefifo_map which actually acts according to plan.But using above mentioned way I have a compilation error(No such directory).Is there any way to include external headers? My submission is here

  • Vote: I like it
  • +4
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

You could always use the reliable:

spoiler
  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    strchr is a C function. OP wants to do things in C++.

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Well it works. Otherwise OP could use a normal if with 5 conditions.

      If he needs something with C++ he could use an unordered_set:

      unordered_set<char> vowels;
      vowels.insert('a');
      vowels.insert('e');
      vowels.insert('i');
      vowels.insert('o');
      vowels.insert('u');
      if(vowels.count(c) == 1)
          // c is a vowel
      else
          // c is a consonant
      
  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks a lot.I just kinda curious if I could solve it using map?

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      unordered_map<char,bool> isVowel;
      
      isVowel['a'] = isVowel['e'] = isVowel['i'] = isVowel['o'] = isVowel['u'] = true;
      
      if(isVowel[c])
          // c is avowel
      else
          // c is a consonant
      
»
4 years ago, # |
  Vote: I like it +12 Vote: I do not like it

You're trying way too hard for a simple problem. You can solve without using unordered_map. I, as a rule of thumb, like to keep things simple wherever they can be kept simple. Even you should try very simple implementations. You should also note that CF will not store every available library implementation available on the internet. We have the STL here only so fifo_map.hpp isn't available, wherever you found it. To use an unordered_map, use the library implementation instead of a third party source.

So, in order to help you solve this problem:

Hint
Hint