Submission #943893

# Submission time Handle Problem Language Result Execution time Memory
943893 2024-03-12T03:57:40 Z vjudge1 Building Skyscrapers (CEOI19_skyscrapers) C++17
0 / 100
116 ms 7084 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()

template<class S, class T>
bool chmin(S &a, const T &b) {
  return a > b ? (a = b) == b : false;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
  return a < b ? (a = b) == b : false;
}

const vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
const vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, t; cin >> n >> t;
  int x[n], y[n];
  map<int, map<int, bool>> used;
  map<int, vector<int>> g;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    used[x[i]][y[i]] = true;
    g[x[i] + y[i]].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    bool flag = false;
    for (int j = 0; j < 8; ++j) {
      if (used[x[i] + dx[j]][y[i] + dy[j]]) {
        flag |= true;
      }
    }
    if (!flag) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  for (auto [k, v] : g) {
    sort(all(v), [&](const int& i, const int& j){
      if (x[i] == x[j]) {
        return y[i] < y[j];
      }
      return x[i] < x[j];
    });
  }
  for (auto [k, v] : g) {
    for (auto i : v) {
      cout << i + 1 << '\n';
    }
  }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant did not find solution
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant did not find solution
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant did not find solution
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 860 KB ans=NO N=1934
2 Correct 1 ms 604 KB ans=NO N=1965
3 Incorrect 2 ms 604 KB Full cells must be connected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant did not find solution
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 7004 KB ans=NO N=66151
2 Correct 35 ms 6400 KB ans=NO N=64333
3 Incorrect 116 ms 7084 KB Full cells must be connected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 860 KB ans=NO N=1934
2 Correct 1 ms 604 KB ans=NO N=1965
3 Incorrect 2 ms 604 KB Full cells must be connected
4 Halted 0 ms 0 KB -