Click
Here to go back to the homepage.
Secure Doors Solution:
#include <bits/stdc++.h>
using namespace std;
int main(){
// #ifndef TESTING
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int actions;
cin >> actions;
string action;
string name;
set<string> ppl_inside;
bool inside = false;
while(actions--){
cin >> action;
cin >> name;
inside = ppl_inside.find(name) != ppl_inside.end();
if(action == "entry"){
cout << name << " entered";
if(inside){
cout << " (ANOMALY)";
} else {
ppl_inside.insert(name);
}
cout << endl;
}
else{
cout << name << " exited";
if(!inside){
cout << " (ANOMALY)";
} else {
ppl_inside.erase(name);
}
cout << endl;
}
}
return 0;
}