Submission #546551

#TimeUsernameProblemLanguageResultExecution timeMemory
546551LucaDantasBuilding Skyscrapers (CEOI19_skyscrapers)C++17
Compilation error
0 ms0 KiB
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()); mark.insert(sk.back()); vector<int> ans; while(q.size()) { ans.push_back(id[q.top()]); auto [x, y] = 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])), mark.insert(pair<int,int>(x+dx[k], y+dy[k])); } if(ans.size() == n) { puts("YES"); for(int x : ans) printf("%d\n", x); } else { puts("NO"); } }

Compilation message (stderr)

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:7:12: error: 'scanf' was not declared in this scope
    7 |     int n; scanf("%d", &n);
      |            ^~~~~
skyscrapers.cpp:12:5: error: 'vector' was not declared in this scope
   12 |     vector<pair<int,int>> sk(n);
      |     ^~~~~~
skyscrapers.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | using namespace std;
skyscrapers.cpp:12:12: error: 'pair' was not declared in this scope
   12 |     vector<pair<int,int>> sk(n);
      |            ^~~~
skyscrapers.cpp:1:1: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
  +++ |+#include <utility>
    1 | using namespace std;
skyscrapers.cpp:12:17: error: expected primary-expression before 'int'
   12 |     vector<pair<int,int>> sk(n);
      |                 ^~~
skyscrapers.cpp:13:24: error: 'sk' was not declared in this scope
   13 |     for(auto& [x, y] : sk)
      |                        ^~
skyscrapers.cpp:16:5: error: 'map' was not declared in this scope
   16 |     map<pair<int,int>, int> id;
      |     ^~~
skyscrapers.cpp:1:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
  +++ |+#include <map>
    1 | using namespace std;
skyscrapers.cpp:16:14: error: expected primary-expression before 'int'
   16 |     map<pair<int,int>, int> id;
      |              ^~~
skyscrapers.cpp:19:9: error: 'id' was not declared in this scope; did you mean 'i'?
   19 |         id[sk[i]] = i+1;
      |         ^~
      |         i
skyscrapers.cpp:19:12: error: 'sk' was not declared in this scope
   19 |         id[sk[i]] = i+1;
      |            ^~
skyscrapers.cpp:21:10: error: 'sk' was not declared in this scope
   21 |     sort(sk.begin(), sk.end());
      |          ^~
skyscrapers.cpp:21:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   21 |     sort(sk.begin(), sk.end());
      |     ^~~~
      |     short
skyscrapers.cpp:23:5: error: 'set' was not declared in this scope
   23 |     set<pair<int,int>> mark;
      |     ^~~
skyscrapers.cpp:1:1: note: 'std::set' is defined in header '<set>'; did you forget to '#include <set>'?
  +++ |+#include <set>
    1 | using namespace std;
skyscrapers.cpp:23:14: error: expected primary-expression before 'int'
   23 |     set<pair<int,int>> mark;
      |              ^~~
skyscrapers.cpp:24:5: error: 'priority_queue' was not declared in this scope
   24 |     priority_queue<pair<int,int>> q;
      |     ^~~~~~~~~~~~~~
skyscrapers.cpp:1:1: note: 'std::priority_queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
  +++ |+#include <queue>
    1 | using namespace std;
skyscrapers.cpp:24:25: error: expected primary-expression before 'int'
   24 |     priority_queue<pair<int,int>> q;
      |                         ^~~
skyscrapers.cpp:25:5: error: 'q' was not declared in this scope
   25 |     q.push(sk.back());
      |     ^
skyscrapers.cpp:26:5: error: 'mark' was not declared in this scope
   26 |     mark.insert(sk.back());
      |     ^~~~
skyscrapers.cpp:28:12: error: expected primary-expression before 'int'
   28 |     vector<int> ans;
      |            ^~~
skyscrapers.cpp:31:9: error: 'ans' was not declared in this scope
   31 |         ans.push_back(id[q.top()]);
      |         ^~~
skyscrapers.cpp:31:23: error: 'id' was not declared in this scope
   31 |         ans.push_back(id[q.top()]);
      |                       ^~
skyscrapers.cpp:36:57: error: expected primary-expression before 'int'
   36 |             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])))
      |                                                         ^~~
skyscrapers.cpp:36:61: error: expected primary-expression before 'int'
   36 |             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])))
      |                                                             ^~~
skyscrapers.cpp:36:16: error: 'binary_search' was not declared in this scope
   36 |             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])))
      |                ^~~~~~~~~~~~~
skyscrapers.cpp:36:105: error: expected primary-expression before 'int'
   36 |             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])))
      |                                                                                                         ^~~
skyscrapers.cpp:36:109: error: expected primary-expression before 'int'
   36 |             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])))
      |                                                                                                             ^~~
skyscrapers.cpp:37:29: error: expected primary-expression before 'int'
   37 |                 q.push(pair<int,int>(x+dx[k], y+dy[k])), mark.insert(pair<int,int>(x+dx[k], y+dy[k]));
      |                             ^~~
skyscrapers.cpp:37:33: error: expected primary-expression before 'int'
   37 |                 q.push(pair<int,int>(x+dx[k], y+dy[k])), mark.insert(pair<int,int>(x+dx[k], y+dy[k]));
      |                                 ^~~
skyscrapers.cpp:37:75: error: expected primary-expression before 'int'
   37 |                 q.push(pair<int,int>(x+dx[k], y+dy[k])), mark.insert(pair<int,int>(x+dx[k], y+dy[k]));
      |                                                                           ^~~
skyscrapers.cpp:37:79: error: expected primary-expression before 'int'
   37 |                 q.push(pair<int,int>(x+dx[k], y+dy[k])), mark.insert(pair<int,int>(x+dx[k], y+dy[k]));
      |                                                                               ^~~
skyscrapers.cpp:40:8: error: 'ans' was not declared in this scope
   40 |     if(ans.size() == n) {
      |        ^~~
skyscrapers.cpp:41:9: error: 'puts' was not declared in this scope
   41 |         puts("YES");
      |         ^~~~
skyscrapers.cpp:43:13: error: 'printf' was not declared in this scope
   43 |             printf("%d\n", x);
      |             ^~~~~~
skyscrapers.cpp:1:1: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
  +++ |+#include <cstdio>
    1 | using namespace std;
skyscrapers.cpp:45:9: error: 'puts' was not declared in this scope
   45 |         puts("NO");
      |         ^~~~