sjp1114's blog

By sjp1114, history, 2 months ago, In English

include <bits/stdc++.h>

using namespace std;

void solve(){ string word; cin >> word; unordered_set s; int count = 0;

for(int i = 0; i < word.size() and word[i] != '\0'; i++){
    //check if x is already not in set s!
    if(s.find(word[i]) !=  s.end()){
        s.insert(word[i]);
        count++;
    }
    //otherwise, it's a character we already saw before!
}

//check for parity!
if(count % 2 == 0){
    cout << "CHAT WITH HER!";
    return;
}

else{
    cout << "IGNORE HIM!";
    return;
}

}

int main(){ solve(); }

 
 
 
 
  • Vote: I like it
  • -14
  • Vote: I do not like it

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by sjp1114 (previous revision, new revision, compare).

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it
s.find(word[i]) !=  s.end() // means word[i] exists in s, you should change it to s.find(word[i]) ==  s.end() and also your code doesn't compile because you miss (1) #include (2) unordered_set<char> s

See this: Your 168035956

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

you don't have to check if a character exists in the set,set doesn't store duplicates,you can keep inserting all the elements,it will only have unique elements.