QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#61669#2615. Surround the CatBooksnowWA 5ms3388kbC++142.1kb2022-11-14 15:36:422022-11-14 15:36:45

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-14 15:36:45]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3388kb
  • [2022-11-14 15:36:42]
  • 提交

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 = 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: 5ms
memory: 3388kb

input:

0 0
1 0
2 1
3 1
4 2
5 2
6 2
7 3
7 2
7 3
7 4
7 5
7 6
7 7
7 6
7 5
7 6
7 7
7 6
7 7
7 6
7 7
6 7
7 7
7 6
7 7
6 7
7 7
7 6
7 5
7 4
7 3
7 2
7 3
7 2
7 1
7 0
6 -1
5 -2
6 -1
7 0
7 1
7 2
7 1
7 2
7 1
7 2
7 1
7 2
7 3
7 2
7 3
7 4
7 5
7 4

output:

9 4
9 0
9 5
9 3
9 6
9 2
9 1
9 7
7 -2
9 8
8 9
9 9
7 9
6 9
5 9
4 9
3 9
2 9
8 -1
1 9
6 -3
-1 8
0 9
-2 7
-3 6
-4 5
-5 4
5 -4
4 -5
3 -6
2 -7
1 -8
-2 -9
-3 -9
-1 -9
0 -9
-4 -9
-5 -9
-6 -9
-7 -9
-8 -9
-7 2
-6 3
-8 1
-9 -4
-9 -5
-9 -3
-9 -6
-9 -2
-9 -7
-9 -1
-9 -8
-9 0
-9 -9

result:

wrong answer format  Unexpected end of file - int32 expected