Submission #1089028

#TimeUsernameProblemLanguageResultExecution timeMemory
1089028LilPlutonBuilding Skyscrapers (CEOI19_skyscrapers)C++14
54 / 100
587 ms56312 KiB
#include <bits/stdc++.h> using namespace std; #define int ll #define ll long long const int inf = 1e9 + 7; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; const int sz = 2e5 + 5; vector<int>moves = {1, 0, -1}; signed main(){ int n, t; cin >> n >> t; vector<pair<int,int>> a(n); vector<pair<pair<int,int>, int>>v; map<pair<int,int>, int> ind, mp; for(int i = 0; i < n; ++i){ cin >> a[i].first >> a[i].second; v.push_back({{a[i].first, a[i].second}, i + 1}); mp[{a[i].first, a[i].second}] = 1; ind[{a[i].first, a[i].second}] = i + 1; } int x = begin(mp) -> first.first; int y = begin(mp) -> first.second; set<pair<int,int>> st; st.insert({x, y}); mp[{x, y}] = 2; vector<int>res; while(!st.empty()){ int x = begin(st)->first; int y = begin(st)->second; st.erase(begin(st)); res.push_back(ind[{x, y}]); for(auto v1 : moves){ for(auto v2 : moves){ if(mp[{x + v1, y + v2}] == 1){ mp[{x + v1, y + v2}] = 2; st.insert({x + v1, y + v2}); } } } } bool ok = true; for(int i = 0; i < n; ++i){ if(mp[{a[i].first, a[i].second}] == 1){ ok = false; } } if(!ok){ cout << "NO" << endl; return 0; } cout << "YES" << endl; for(auto &i : res){ cout << i << 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...