Submission #564856

#TimeUsernameProblemLanguageResultExecution timeMemory
564856birthdaycakeBuilding Skyscrapers (CEOI19_skyscrapers)C++17
54 / 100
288 ms24912 KiB
#include<bits/stdc++.h> #define int long long #define endl '\n' #define mod 1000000007 #define boost ios_base::sync_with_stdio(false), cin.tie(NULL); using namespace std; int xx[] = {-1,-1,-1,0,1,1,1,0}, yy[] = {-1,0,1,1,1,0,-1,-1}; signed main(){ boost; int n,t; cin >> n >> t; vector<pair<int,pair<int,int>>>d(n); vector<int>ans; map<pair<int,int>,int>o; for(int i = 0; i < n; i++){ cin >> d[i].first >> d[i].second.first; d[i].second.second = i + 1; o[{d[i].first,d[i].second.first}] = i + 1; } int x = -1e18, y = -1e18, j = 0; set<pair<int,pair<int,int>>>c; set<pair<int,int>>a; for(int i = 0; i < n; i++){ if(d[i].first > x){ x = d[i].first; y = d[i].second.first; j = i + 1; }else if(d[i].first == x && d[i].second.first > y){ x = d[i].first; y = d[i].second.first; j = i + 1; } a.insert({d[i].first,d[i].second.first}); } a.erase({x,y}); c.insert({x,{y,j}}); while(c.size()){ auto f = *c.begin(); ans.push_back(f.second.second); c.erase(c.begin()); for(int i = 0; i < 8; i++){ int aa = f.first + xx[i], b = f.second.first + yy[i]; if(!a.count({aa,b})) continue; c.insert({aa,{b,o[{aa,b}]}}); a.erase({aa,b}); } } if(ans.size() < n){ cout << "NO"; return 0; } cout << "YES" << endl; for(int i = 0; i < n ;i++){ cout << ans[i] << endl; } return 0; }

Compilation message (stderr)

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:56:19: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   56 |     if(ans.size() < 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...