How to solve 987A-Infinity Gauntlet without using map

Revision en4, by akshaJ_J, 2020-04-02 09:47:34

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's my attempt. ~~~~~

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"}; vectormissing; 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; } ~~~~~

Tags #implementation, #help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en7 English akshaJ_J 2020-04-02 09:49:16 0 (published)
en6 English akshaJ_J 2020-04-02 09:48:57 17 Tiny change: 'in advance\n\n~~~~~' -> 'in advance. Here is my code\n\n~~~~~'
en5 English akshaJ_J 2020-04-02 09:48:06 18 Tiny change: ' advance\nHere's my attempt.\n~~~~~\n#' -> ' advance\n\n~~~~~\n#' (saved to drafts)
en4 English akshaJ_J 2020-04-02 09:47:34 0 (published)
en3 English akshaJ_J 2020-04-02 09:46:17 18 Tiny change: ' advance\n\n~~~~~\n#' -> ' advance\nHere's my attempt.\n~~~~~\n#'
en2 English akshaJ_J 2020-04-02 09:45:27 5 Tiny change: 'pop_back()). I want ' -> 'pop_back(),etc). I want '
en1 English akshaJ_J 2020-04-02 09:44:59 1514 Initial revision (saved to drafts)