you can use here "?:" construction:
std::cout << ( my_set.find( temp ) != my_set.end() ? "YES" : "NO" ) << std::endl;