akshaJ_J's blog

By akshaJ_J, history, 5 years ago, In English

I am just a beginner in competitive programming and not familiar with C++ STL. I know only basics of vector STL(like push_back(),erase,basic traversing in vector,pop_back(),etc). I want to know how to solve Infinity Gauntlet without using map concept. I tried to solve without using map but in the custom test I am getting a runtime error. Please help and thanks in advance. Here is my code

#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(NULL);ios_base::sync_with_stdio(false);
    string color[]={"red","purple","green","blue","yellow","orange"},specific;
    string stones[]={"Reality","Power","Time","Space","Mind","Soul"};
    vector<string>missing;
    missing.push_back("Reality");
    missing.push_back("Power");
    missing.push_back("Time");
    missing.push_back("Space");
    missing.push_back("Mind");
    missing.push_back("Soul");
    int i,n;
    cin>>n;
    while(n--)
    {
        cin>>specific;
        for(i=0;i<6;i++)
        {
            if(color[i]==specific)
            {
                for(auto it2=missing.begin();it2!=missing.end();it2++)
                {
                    if(*it2==stones[i])
                     missing.erase(it2);
                }
            }    
        }
    }
    cout<<6-n<<"\n";
    for(auto it=missing.begin();it!=missing.end();it++)
    {
        cout<<*it<<"\n";
    }
    return 0;
}

Full text and comments »

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