Submission #985838

#TimeUsernameProblemLanguageResultExecution timeMemory
985838duckindogBuilding Skyscrapers (CEOI19_skyscrapers)C++17
0 / 100
48 ms11472 KiB
#include <bits/stdc++.h> using namespace std; const int N = 150'000 + 10, dx[8] = {-1, 0, 1, -1, 1, 1, 0, -1}, dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; int n, type; struct Point { int r, c, idx; bool operator > (const auto& rhs) { return make_pair(r, c) > make_pair(rhs.r, rhs.c); } friend ostream& operator << (ostream& os, const auto& rhs) { return os << rhs.r << " " << rhs.c << " " << rhs.idx; } } p[N]; unordered_map<int, unordered_map<int, int>> rvs; bool mk[N]; vector<int> answer; void dfs(int idx) { int r = p[idx].r, c = p[idx].c; answer.push_back(idx); for (int i = 0; i < 8; ++i) { int nR = r + dx[i], nC = c + dy[i], nxt = rvs[nR][nC]; if (!nxt || mk[nxt]) continue; mk[nxt] = true; dfs(nxt); if (i >= 5) break; } } int32_t main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> type; for (int i = 1; i <= n; ++i) { int r, c; cin >> r >> c; p[i] = {r, c, i}; rvs[r][c] = i; } Point st = p[1]; for (int i = 1; i <= n; ++i) if (st > p[i]) st = p[i]; mk[st.idx] = true; dfs(st.idx); if (answer.size() != n) { cout << "No\n"; return 0; }; cout << "YES\n"; for (const auto& x : answer) cout << x << "\n"; }

Compilation message (stderr)

skyscrapers.cpp:12:25: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   12 |  bool operator > (const auto& rhs) {
      |                         ^~~~
skyscrapers.cpp:15:50: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   15 |  friend ostream& operator << (ostream& os, const auto& rhs) {
      |                                                  ^~~~
skyscrapers.cpp: In function 'int32_t main()':
skyscrapers.cpp:52:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |  if (answer.size() != n) { cout << "No\n"; return 0; };
      |      ~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...