Submission #810989

#TimeUsernameProblemLanguageResultExecution timeMemory
810989treewaveBuilding Skyscrapers (CEOI19_skyscrapers)C++17
0 / 100
31 ms5688 KiB
#include <bits/stdc++.h> using namespace std; int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1}; int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1}; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, t; cin >> n >> t; vector<array<int, 2>> points; set<array<int, 3>> points_set; for (int i = 0; i < n; i++){ int x, y; cin >> x >> y; points.push_back({x, y}); points_set.insert({x, y, i}); } set<array<int, 2>> visited; vector<int> ans; while (!points_set.empty()){ array<int, 3> tp = *points_set.begin(); points_set.erase(points_set.begin()); bool good = false; for (int d = 0; d < 8; d++){ if (visited.count({tp[0]+dx[d], tp[1]+dy[d]})){ good = true; break; } } if (!good && !ans.empty()){ cout << "NO\n"; return 0; } visited.insert({tp[0], tp[1]}); ans.push_back(tp[2]); } reverse(ans.begin(), ans.end()); cout << "YES\n"; for (int i = 0; i < n; i++){ cout << ans[i]+1 << "\n"; } }
#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...