Artifact 01a2602f05b036ac5c8770b88c89bf824f5222d4
//-------------------------------------------------------------
// ID Assignment
//
// Verified by
// - ACM/ICPC Tokyo 2010 A
// - SRM 491 Div1 LV3
//-------------------------------------------------------------
template<typename T>
class IdGen
{
map<T, int> v2id_;
vector<T> id2v_;
public:
int v2id(const T& v) {
if( !v2id_.count(v) ) { v2id_[v] = size(); id2v_.push_back(v); }
return v2id_[v];
}
const T& id2v(int i) const { return id2v_[i]; }
int size() const { return id2v_.size(); }
};