就是说,我先定义了一个 set
struct node{ll id,x,val;};
set<node>S;
然后,这是用到 set 的代码
inline void add(ll id,ll x,ll v)
{
ll t=x%p[id];
S.erase((node){id,t,f[id][t]});
f[id][t]+=v*p[id];
S.insert((node){id,t,f[id][t]});
}
但是,我的 < 的 operator 这样写就会有 WA
inline bool operator <(const node &a,const node &b){return a.val<b.val;}
而这样写就没问题了
inline bool operator <(const node &a,const node &b){return a.val<b.val||(a.val==b.val&&a.x<b.x)||(a.val==b.val&&a.x==b.x&&a.id<b.id);}
请问这是为什么呢?(在求解问题时只需要求 val 最大,id 和 x 不重要)