when i wrote the code using small to larger techinque,
if i write code like
if((int)s.size()<(int)s1.size()){
for(set<pair<lld,int> >::iterator it = s.begin();it!=s.end();it++) s1.insert(*it);
s = s1;
}else{
for(set<pair<lld,int> >::iterator it = s1.begin();it!=s1.end();it++) s.insert(*it);
}
it gets TLE ( problem accept 4 second )
but if i write code like
if((int)s.size()<(int)s1.size()){
for(set<pair<lld,int> >::iterator it = s.begin();it!=s.end();it++) s1.insert(*it);
swap(s,s1);
}else{
for(set<pair<lld,int> >::iterator it = s1.begin();it!=s1.end();it++) s.insert(*it);
}
it gets AC and run so fast ( runnging time is 200ms )
but i don't know why difference of time is so big.. help..