@[gzf2008](/user/216248) 插入结构体?这样应该可以,例如:
```cpp
struct point {
double x, y;
};
set<point> s;
```
by Zlc晨鑫 @ 2020-04-06 09:50:31
@[Zlc晨鑫](/user/297555) 不是你没重载小于号怎么做
by critnos @ 2020-04-06 09:52:08
~~为什么越看越像平衡树~~
by Prean @ 2020-04-06 09:56:56
@[_26535_](/user/203623) 差点忘了
by Zlc晨鑫 @ 2020-04-06 09:59:18
@[Zlc晨鑫](/user/297555) 你没重载小于号啊……
显然会 CE 吧。
by Clever_Jimmy @ 2020-04-06 09:59:30
@[gzf2008](/user/216248) 然后你还要重载小于号
by Zlc晨鑫 @ 2020-04-06 09:59:36
### 我这为啥编译不通过?
```cpp
#include<bits/stdc++.h>
using namespace std;
struct node
{
int x,y;
};
set<node>a;
inline int read()
{
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s<<3+s<<1+ch-'0',ch=getchar();
return s*w;
}
int main()
{
int n,opt,x,y;
n=read();
for(int i=1;i<=n;i++)
{
opt=read();x=read();y=read();
if(opt==1) a.insert(node{x,y});
else
{
if(a.upper_bound(node{x,y})!=a.end())
{
int x1=a.upper_bound(node.x),y1=a.upper_bound(node.y);
cout<<abs(x-x1)+abs(y-y1)<<endl;
}
else cout<<-1<<endl;
}
}
return 0;
}
```
by gzf2008 @ 2020-04-06 10:00:02
@[gzf2008](/user/216248) 其实弄个pair就行了
by critnos @ 2020-04-06 10:00:50
倒数第八行错了
by gzf2008 @ 2020-04-06 10:01:36
好像要封装
by Minecraft万岁 @ 2020-04-06 10:01:48