放 pair
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>TL;
map<TL,int>s;
int main(){
TL a;
a.first = 1,a.second = 2;
s[a] = 1;
cout << s[a];
}
放结构体
题目链接:点击打开链接
#include<bits/stdc++.h>
using namespace std;
struct Test
{
long long x;
long long y;
//long long z;//三个元素
bool operator < (const Test &o) const
{
return x < o.x || y < o.y ;// 在分号前加 : || z < o.z
}
}s;
int x[100005],y[100005];
map<Test,long long>a;
int main(){
long long n,x1,y1,x2,y2;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> x1 >> y1 >> x2 >> y2;
s.x = x2 - x1;
s.y = y2 - y1;
x[i] = s.x;
y[i] = s.y;
a[s]++;
}
int ans = -1,xx,yy;
for(int i = 1;i <= n;i++){
s.x = x[i],s.y = y[i];
if(a[s] > ans){
xx = x[i];
yy = y[i];
ans = a[s];
}
}
s.x = xx,s.y = yy;
if(a[s] >= n / 2) cout << xx << ' ' << yy;
else cout << xx << ' ' << yy;
}