답안 #420420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
420420 2021-06-08T11:00:51 Z rama_pang Izvanzemaljci (COI21_izvanzemaljci) C++17
5 / 100
121 ms 5260 KB
#include <bits/stdc++.h>
using namespace std;

using lint = long long;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int N, K;
  cin >> N >> K;

  vector<lint> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }

  const auto Solve = [&](const auto &self, lint L, int k, vector<int> dead) -> pair<bool, vector<pair<int, int>>> {
    if (count(begin(dead), end(dead), 1) == N) {
      return {true, vector<pair<int, int>>(k, {0, 0})};
    }
    if (k == 0) {
      return {false, vector<pair<int, int>>()};
    }
    lint minX = +2e9;
    lint maxX = -2e9;
    lint minY = +2e9;
    lint maxY = -2e9;
    for (int i = 0; i < N; i++) if (!dead[i]) {
      minX = min(minX, X[i]);
      maxX = max(maxX, X[i]);
      minY = min(minY, Y[i]);
      maxY = max(maxY, Y[i]);
    }
    for (auto x : {minX, maxX - L}) {
      for (auto y : {minY, maxY - L}) {
        vector<int> newDead = dead;
        for (int i = 0; i < N; i++) if (!dead[i]) {
          if (x <= X[i] && X[i] <= x + L && y <= Y[i] && Y[i] <= y + L) {
            newDead[i] = 1;
          }
        }
        auto res = self(self, L, k - 1, newDead);
        if (res.first) {
          res.second.emplace_back(x, y);
          return res;
        }
      }
    }
    return {false, vector<pair<int, int>>()};
  };

  lint lo = 1, hi = 2e9;
  while (lo < hi) {
    lint md = (lo + hi) / 2;
    if (Solve(Solve, md, K, vector<int>(N, 0)).first) {
      hi = md;
    } else {
      lo = md + 1;
    }
  }

  auto ans = Solve(Solve, lo, K, vector<int>(N, 0)).second;
  for (int i = 0; i < K; i++) {
    cout << ans[i].first << ' ' << ans[i].second << ' ' << lo << '\n';
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 96 ms 5080 KB Output is correct
8 Correct 109 ms 5212 KB Output is correct
9 Correct 103 ms 5232 KB Output is correct
10 Correct 103 ms 5260 KB Output is correct
11 Correct 121 ms 5096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -