Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cmath>
- #include <iostream>
- #include <sstream>
- #include <algorithm>
- #include <string>
- #include<vector>
- #include <istream>
- #include<iomanip>
- #include<stack>
- using namespace std;
- struct item {
- int tid;
- int x;
- int y;
- item(){}
- item(int _tid, int _x, int _y) {
- tid = _tid;
- x = _x;
- y = _y;
- }
- void scan() {
- cin >> tid >> x >> y;
- }
- };
- double lenght(double x, double y, double x1, double y1) {
- return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
- }
- bool cmp(item a, item b) {
- return a.x < b.x || a.x == b.x && a.y < b.y;
- }
- int main(){
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif // _DEBUG
- int n, m;
- cin >> n >> m;
- vector<item> A(n), B(m);
- for (int i = 0; i < n; i++) {
- A[i].scan();
- }
- sort(A.begin(), A.end(), cmp);
- for (int i = 0; i < m; i++) {
- B[i].scan();
- }
- double ans = 1e9;
- int x = 0, y = 0;
- for (int i = 0; i < m; i++) {
- double cnt = 0;
- for (int j = 0; j < n; j++) {
- double l = lenght(A[j].x, A[j].y, B[i].x, B[i].y);
- if (A[j].tid != B[i].tid)
- l = l * 2;
- cnt += l;
- }
- if (ans > cnt) {
- ans = cnt;
- x = B[i].x;
- y = B[i].y;
- }
- }
- cout << x << " " << y;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement