- Debugging is HARD!
题解
- 2024-8-16 10:47:45 @
#include <bits/stdc++.h>
#include <algorithm>
#define endl '\n';
const int N = 1e6 + 10;
const int M = 2e6 + 10;
const int P = 998244353;
const int Base = 3221225477;
const int INF = 0x3f3f3f3f3f3f3f3f;
int mod(int x)
{
return x % P;
}
struct node{
int dis;
int id;
};
using namespace std;
bool cmp(node a,node b)
{
if(a.dis != b.dis)
{
return a.dis < b.dis;
}else if(a.dis == b.dis)
{
return a.id < b.id;
}
}
int n,m;
signed main()
{
cin >> n >> m;
int a[n][2];
int b[m][2];
node c[m];
for(int i = 0; i<n;i++)
{
cin >> a[i][0] >>a[i][1];
}
for(int i = 0; i<m;i++)
{
cin >> b[i][0] >>b[i][1];
}
for(int i = 0;i < n;i++)
{
int x = a[i][0];int y = a[i][1];
for(int j = 0;j < m;j++)
{
int dis = abs(x - b[j][0]) + abs(y - b[j][1]);
c[j].dis = dis;
c[j].id = j+1;
}
sort(c,c+m,cmp);
cout << c[0].id << endl;
}
return 0;
}
0 条评论
目前还没有评论...
信息
- ID
- 250
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- (无)
- 递交数
- 114
- 已通过
- 30
- 上传者