QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#61665 | #2615. Surround the Cat | Booksnow | WA | 1ms | 3316kb | C++14 | 2.1kb | 2022-11-14 15:33:32 | 2022-11-14 15:33:33 |
Judging History
answer
#include <bits/stdc++.h>
#define st first
#define nd second
#define db double
#define re register
#define pb push_back
#define mk make_pair
#define int long long
#define ldb long double
#define pii pair<int, int>
#define ull unsigned long long
#define mst(a, b) memset(a, b, sizeof(a))
using namespace std;
const int N = 1e5 + 10, INF = 1e15;
const int bl[54][2] = {{9, 0}, {9, 1}, {9, 2}, {9, 3}, {9, 4}, {9, 5}, {9, 6}, {9, 7}, {9, 8}, {9, 9}, {8, 9}, {7, 9}, {6, 9}, {5, 9}, {4, 9}, {3, 9}, {2, 9}, {1, 9}, {0, 9}, {-1, 8}, {-2, 7}, {-3, 6}, {-4, 5}, {-5, 4}, {-6, 3}, {-7, 2}, {-8, 1}, {-9, 0}, {-9, -1}, {-9, -2}, {-9, -3}, {-9, -4}, {-9, -5}, {-9, -6}, {-9, -7}, {-9, -8}, {-9, -9}, {-8, -9}, {-7, -9}, {-6, -9}, {-5, -9}, {-4, -9}, {-3, -9}, {-2, -9}, {-1, -9}, {0, -9}, {1, -8}, {2, -7}, {3, -6}, {4, -5}, {5, -4}, {6, -3}, {7, -2}, {8, -1}};
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 * 10 + ch - '0', ch = getchar();
return s * w;
}
bool vis[54];
inline int dis(int ax, int ay, int bx, int by) //计算位置
{
//从 (ax,ay) 到 (bx,by) 的最短步数
int dx = ax - bx, dy = ay - by, res = 0;
if(dx < 0 && dy < 0) ax -= max(dx, dy), ay -= max(dx, dy), res = abs(max(dx, dy));
if(dx > 0 && dy > 0) ax -= min(dx, dy), ay -= min(dx, dy), res = abs(min(dx, dy));
dx = ax - bx, dy = ay - by;
res = res + abs(dx), res = abs(dy);
return res;
}
inline void query(int x, int y)
{
int mi = INF, k;
vector<int> v;
for(re int i = 0; i < 54; i++){
if(vis[i]) continue;
int d = dis(x, y, bl[i][0], bl[i][1]);
if(d < mi) mi = d, v.clear(), v.pb(i);
else if(d == mi) v.pb(i);
}
mi = INF;
for(re int i : v){
int res = 0;
for(re int j : v) if(i != j) res = res + dis(bl[i][0], bl[i][1], bl[j][0], bl[j][1]);
if(res < mi) mi = res, k = i;
}
vis[k] = true;
cout << bl[k][0] << " " << bl[k][1] << "\n", cout.flush();
}
signed main()
{
for(re int i = 0, x, y; i < 54; i++) cin >> x >> y, query(x, y); //只需要放入 54 个块
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3316kb
input:
0 0 1 0 2 1 3 2 4 3 5 4 6 4 7 4 7 3 7 4 7 5 7 4 7 5 7 6 7 5 7 4 7 5 7 6 7 7 7 8 7 9
output:
9 4 9 3 9 5 9 6 9 7 9 8 -9 -3 -9 -4 -9 -6 -9 -2 -9 -1 -9 -5 -9 0 -3 6 -9 -7 -9 -8 -8 1 -4 5 9 9 8 9 7 9
result:
wrong answer Cat reaches the boundary 7 9