Submission #564835

# Submission time Handle Problem Language Result Execution time Memory
564835 2022-05-19T18:56:22 Z 1zaid1 Building Skyscrapers (CEOI19_skyscrapers) C++17
Compilation error
0 ms 0 KB
#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<int, int> ok;
    vector<point> v(n);
    for (auto&i:v) cin >> i.x >> i.y;
    for (auto [x, y, i]:v) ok[x*2e9+y] = ++ind;
    priority_queue<point> q;
    q.push(*min_element(v.begin(), v.end()));

    while (!q.empty()) {
        ans.push_back(q.top());
        auto [x, y, k] = q.top(); q.pop();
        for (auto [i, j]:st) {
            if (ok[(x+i)*2e9+(y+j)]) {
                q.push({x+i, y+j, ok[(x+i)*2e9+(y+j)]});
                ok[(x+i)*2e9+(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

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:27:30: error: no matching function for call to 'std::vector<long long int>::push_back(const value_type&)'
   27 |         ans.push_back(q.top());
      |                              ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from skyscrapers.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'const value_type' {aka 'const point'} to 'const value_type&' {aka 'const long long int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'const value_type' {aka 'const point'} to 'std::vector<long long int>::value_type&&' {aka 'long long int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
skyscrapers.cpp:37: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]
   37 |     if (ans.size() == n) {
      |         ~~~~~~~~~~~^~~~