Submission #564849

#TimeUsernameProblemLanguageResultExecution timeMemory
5648491zaid1Building Skyscrapers (CEOI19_skyscrapers)C++17
54 / 100
338 ms43068 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define int long long typedef long long ll; const int M = 2e6 + 5, MOD = 1e9+7; struct point {int x, y, i;}; bool operator<(point a, point b) {if (a.x == b.x) return a.y < b.y; return a.x < b.x;} vector<pair<int, int>> st = {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}}; signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); srand(time(0)); int n, t, ind = 0; cin >> n >> t; vector<int> ans; map<pair<int, int>, int> ok; vector<point> v(n); for (auto&i:v) cin >> i.x >> i.y; for (auto&[x,y,i]:v) {x+=1e9+9;y+=1e9+9;} for (auto&[x, y, i]:v) i = ++ind; for (auto [x, y, i]:v) ok[{x, y}] = i; priority_queue<point> q; q.push(*max_element(v.begin(), v.end())); ok[{max_element(v.begin(), v.end())->x, max_element(v.begin(), v.end())->y}] = 0; while (!q.empty()) { ans.push_back(q.top().i); auto [x, y, k] = q.top(); q.pop(); for (auto [i, j]:st) { if (ok[{(x+i), (y+j)}]) { q.push({x+i, y+j, ok[{(x+i), (y+j)}]}); ok[{(x+i), (y+j)}] = 0; } } } if (ans.size() == n) { cout << "YES" << endl; for (int i:ans) cout << i << endl; } else cout << "NO" << endl; return 0; } /* 3 2 0 0 0 1 0 2 */

Compilation message (stderr)

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:39:20: 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]
   39 |     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...