| 比赛 |
2026.4.4 |
评测结果 |
AAAAA |
| 题目名称 |
For the Champion |
最终得分 |
100 |
| 用户昵称 |
LikableP |
运行时间 |
0.018 s |
| 代码语言 |
C++ |
内存使用 |
3.75 MiB |
| 提交时间 |
2026-04-04 11:22:43 |
显示代码纯文本
//#include "grader.cpp"
#include "robot.h"
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#define UP 1
#define DOWN 2
#define LEFT 3
#define RIGHT 4
typedef long long ll;
const ll INF = 1e9;
void init(int c, int t) {
c = t = c;
}
struct Point {
ll x, y;
void Print() {
printf("[%lld %lld]\n", x, y);
}
} upright, downright, UPRIGHT = {INF << 2, INF << 2}, DOWNRIGHT = {INF << 2, -INF << 2};
long long getDis(Point x, Point y) {
return llabs(x.x - y.x) + llabs(x.y - y.y);
}
std::pair<int, int> robot(int n, std::vector<int> x, std::vector<int> y) {
std::vector<Point> points;
for (int i = 0; i < n; ++i) {
points.push_back({x[i], y[i]});
}
// std::sort(points.begin(), points.end(), [](Point x, Point y) {
// return x.x + x.y > y.x + y.y;
// });
// upright = points[0];
// std::sort(points.begin(), points.end(), [](Point x, Point y) {
// return x.x - x.y > y.x - y.y;
// });
// downright = points[0];
ll temp = 1e18;
for (Point p : points) {
if (getDis(p, DOWNRIGHT) < temp) {
temp = getDis(p, DOWNRIGHT);
downright = p;
}
}
temp = 1e18;
for (Point p : points) {
if (getDis(p, UPRIGHT) < temp) {
temp = getDis(p, UPRIGHT);
upright = p;
}
}
move(UP, INF), move(UP, INF), move(RIGHT, INF);
ll disToUpRight = move(RIGHT, INF);
move(DOWN, INF), move(DOWN, INF), move(DOWN, INF);
ll disToDownRight = move(DOWN, INF);
ll twiceVerticalDis = disToUpRight + disToDownRight + (upright.y - downright.y) - (INF << 2);
ll horizontalCoordinate = (twiceVerticalDis + upright.x + downright.x) >> 1;
ll xshift = horizontalCoordinate - upright.x;
ll yshift = disToUpRight - xshift;
return {upright.x + xshift - (INF << 1), upright.y + yshift - (INF << 1)};
}