Submission #546550

#TimeUsernameProblemLanguageResultExecution timeMemory
546550LucaDantasBuilding Skyscrapers (CEOI19_skyscrapers)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; const int dx[] = {0, 0, 1, 1, 1, -1, -1, -1}; const int dy[] = {1, -1, 1, -1, 0, 1, -1, 0}; int main() { int n; scanf("%d", &n); int t; scanf("%d", &t); if(t == 2) return 0; // return to this subtask after coding t = 1 vector<pair<int,int>> sk(n); for(auto& [x, y] : sk) scanf("%d %d", &x, &y); map<pair<int,int>, int> id; for(int i = 0; i < n; i++) id[sk[i]] = i+1; sort(sk.begin(), sk.end()); set<pair<int,int>> mark; priority_queue<pair<int,int>> q; q.push(sk.back()); vector<int> ans; while(q.size()) { ans.push_back(id[q.top()]); auto [x, y] = q.top(); mark.insert(q.top()); q.pop(); for(int k = 0; k < 8; k++) if(binary_search(sk.begin(), sk.end(), pair<int,int>(x+dx[k], y+dy[k])) && !mark.count(pair<int,int>(x+dx[k], y+dy[k]))) q.push(pair<int,int>(x+dx[k], y+dy[k])); } if(ans.size() == n) { puts("YES"); for(int x : ans) printf("%d\n", x); } else { assert(0); // puts("NO"); } }

Compilation message (stderr)

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:41:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |     if(ans.size() == n) {
      |        ~~~~~~~~~~~^~~~
skyscrapers.cpp:8:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     int n; scanf("%d", &n);
      |            ~~~~~^~~~~~~~~~
skyscrapers.cpp:9:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     int t; scanf("%d", &t);
      |            ~~~~~^~~~~~~~~~
skyscrapers.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#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...