Submission #234919

#TimeUsernameProblemLanguageResultExecution timeMemory
234919RiscadoABuilding Skyscrapers (CEOI19_skyscrapers)C++14
54 / 100
523 ms14780 KiB
#include <bits/stdc++.h> using namespace std; int N, T; map<pair<int, int>, int> P; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> T; for (int i = 0, r, c; i < N; ++i) { cin >> r >> c; P.insert({{ r, c }, i }); } if (T == 1) { vector<int> s; map<pair<int, int>, int> candidates; candidates.insert(*P.begin()); P.erase(P.begin()); while (!candidates.empty()) { auto node = *candidates.begin(); candidates.erase(candidates.begin()); s.push_back(node.second); for (int i = -1; i <= 1; ++i) { for (int j = -1; j <= 1; ++j) { if (i == 0 && j == 0) { continue; } auto it = P.find({ node.first.first + i, node.first.second + j }); if (it != P.end()) { candidates.insert(*it); P.erase(it); } } } } if (!P.empty()) { cout << "NO" << endl; } else { cout << "YES" << endl; for (const auto& i : s) { cout << (i + 1) << endl; } } } }
#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...