Submission #571120

# Submission time Handle Problem Language Result Execution time Memory
571120 2022-06-01T09:40:00 Z web Building Skyscrapers (CEOI19_skyscrapers) C++17
Compilation error
0 ms 0 KB
#include <functional>
#include <queue>
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;
typedef long long ll;
vector<bitset<2*1000000001>> grid;
void setBits(int x,int y)
{
    for(int i = x-1; i<= x+1; ++i)
    {
        for(int j = y-1; j<= y+1; ++j)
        {
            grid[x].set(y);
        }
    }
}


bool isAdjacent(pair<long, pair<long, int>>s1, pair<long, pair<long, int>>s2)
  {  return abs(s1.first -s2.first ) <= 1 && abs(s1.second.first - s2.second.first) <=1;}

bitset<150000> visited;
vector<vector<int>> adjList;
vector<pair<long,pair<long, int>>> buildings;
vector<int> order;


long calcManhattenDist(int i, int j)
{
    return abs(buildings[i].first - buildings[j].first) + abs(buildings[i].second.first - buildings[j].second.first);
}


void BFS(int startNode)
{
    auto comp = [startNode](int lhs, int rhs) -> bool
    {
       return buildings[lhs] > buildings[rhs];//calcManhattenDist(startNode, lhs) > calcManhattenDist(startNode, rhs);
    };
    priority_queue<int, vector<int>, decltype( comp)> nodeList;
    nodeList.push(startNode);
    visited.set(startNode);
    while(nodeList.size() != 0)
    {
        int newNode = nodeList.top();
        nodeList.pop();
       
        order.push_back(newNode);
        for(auto node:adjList[newNode])
        {
            if(!visited.test(node))
            {
                nodeList.push(node);
                visited.set(node);
            }
        }
    }
}

int main()
{
    int n; cin>>n;
    int t; cin>>t;
    buildings.resize(n);
    for(int i = 0; i<n; ++i)
    {
        long a; long b; cin>>a>>b;
        buildings[i] = {a,{b, i}};
    }
    adjList.resize(n);
    sort(buildings.begin(), buildings.end());
    for(int i = 0; i<n-1; ++i)
    {
        for(int j = i+1; j<n; ++j)
        {
            if(buildings[j].first - buildings[i].first > 1)
                break;
            else
            {
                if(isAdjacent(buildings[i], buildings[j]))
                {
                    adjList[i].push_back(j);
                    adjList[j].push_back(i);
                }
            }
        }
    }
    
    //DFS
    BFS(0);
    for(int i = 0; i<n; ++i)
    {
        if(!visited.test(i))
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    for(int i = 0; i<n; ++i)
    {
        cout<<buildings[order[i]].second.second+1<<endl;
    }
    return 0;
}

Compilation message

skyscrapers.cpp: In function 'void BFS(int)':
skyscrapers.cpp:44:55: error: no matching function for call to 'std::priority_queue<int, std::vector<int>, BFS(int)::<lambda(int, int)> >::priority_queue()'
   44 |     priority_queue<int, vector<int>, decltype( comp)> nodeList;
      |                                                       ^~~~~~~~
In file included from /usr/include/c++/10/queue:64,
                 from skyscrapers.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:597:2: note: candidate: 'template<class _InputIterator> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&) [with _InputIterator = _InputIterator; _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  597 |  priority_queue(_InputIterator __first, _InputIterator __last,
      |  ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:597:2: note:   template argument deduction/substitution failed:
skyscrapers.cpp:44:55: note:   candidate expects 4 arguments, 0 provided
   44 |     priority_queue<int, vector<int>, decltype( comp)> nodeList;
      |                                                       ^~~~~~~~
In file included from /usr/include/c++/10/queue:64,
                 from skyscrapers.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:586:2: note: candidate: 'template<class _InputIterator> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&) [with _InputIterator = _InputIterator; _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  586 |  priority_queue(_InputIterator __first, _InputIterator __last,
      |  ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:586:2: note:   template argument deduction/substitution failed:
skyscrapers.cpp:44:55: note:   candidate expects 4 arguments, 0 provided
   44 |     priority_queue<int, vector<int>, decltype( comp)> nodeList;
      |                                                       ^~~~~~~~
In file included from /usr/include/c++/10/queue:64,
                 from skyscrapers.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:554:2: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  554 |  priority_queue(priority_queue&& __q, const _Alloc& __a)
      |  ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:554:2: note:   template argument deduction/substitution failed:
skyscrapers.cpp:44:55: note:   candidate expects 2 arguments, 0 provided
   44 |     priority_queue<int, vector<int>, decltype( comp)> nodeList;
      |                                                       ^~~~~~~~
In file included from /usr/include/c++/10/queue:64,
                 from skyscrapers.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:550:2: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  550 |  priority_queue(const priority_queue& __q, const _Alloc& __a)
      |  ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:550:2: note:   template argument deduction/substitution failed:
skyscrapers.cpp:44:55: note:   candidate expects 2 arguments, 0 provided
   44 |     priority_queue<int, vector<int>, decltype( comp)> nodeList;
      |                                                       ^~~~~~~~
In file included from /usr/include/c++/10/queue:64,
                 from skyscrapers.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:545:2: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  545 |  priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
      |  ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:545:2: note:   template argument deduction/substitution failed:
skyscrapers.cpp:44:55: note:   candidate expects 3 arguments, 0 provided
   44 |     priority_queue<int, vector<int>, decltype( comp)> nodeList;
      |                                                       ^~~~~~~~
In file included from /usr/include/c++/10/queue:64,
                 from skyscrapers.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:539:2: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  539 |  priority_queue(const _Compare& __x, const _Sequence& __c,
      |  ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:539:2: note:   template argument deduction/substitution failed:
skyscrapers.cpp:44:55: note:   candidate expects 3 arguments, 0 provided
   44 |     priority_queue<int, vector<int>, decltype( comp)> nodeList;
      |                                                       ^~~~~~~~
In file included from /usr/include/c++/10/queue:64,
                 from skyscrapers.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:533:2: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  533 |  priority_queue(const _Compare& __x, const _Alloc& __a)
      |  ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:533:2: note:   template argument deduction/substitution failed:
skyscrapers.cpp:44:55: note:   candidate expects 2 arguments, 0 provided
   44 |     priority_queue<int, vector<int>, decltype( comp)> nodeList;
      |                                                       ^~~~~~~~
In file included from /usr/include/c++/10/queue:64,
                 from skyscrapers.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:529:2: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  529 |  priority_queue(const _Alloc& __a)
      |  ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:529:2: note:   template argument deduction/substitution failed:
skyscrapers.cpp:44:55: note:   candidate expects 1 argument, 0 provided
   44 |     priority_queue<int, vector<int>, decltype( comp)> nodeList;
      |                                                       ^~~~~~~~
In file included from /usr/include/c++/10/queue:64,
                 from skyscrapers.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:523:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  523 |       priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
      |       ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:523:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/10/bits/stl_queue.h:518:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  518 |       priority_queue(const _Compare& __x, const _Sequence& __s)
      |       ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:518:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/10/bits/stl_queue.h:514:2: note: candidate: 'template<class _Seq, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Seq = _Seq; _Requires = _Requires; _Tp = int; _Sequence = std::vector<int>; _Compare = BFS(int)::<lambda(int, int)>]'
  514 |  priority_queue()
      |  ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:514:2: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/stl_queue.h:511:43: error: no type named 'type' in 'struct std::enable_if<false, void>'
  511 |       template<typename _Seq = _Sequence, typename _Requires = typename
      |                                           ^~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:456:11: note: candidate: 'std::priority_queue<int, std::vector<int>, BFS(int)::<lambda(int, int)> >::priority_queue(const std::priority_queue<int, std::vector<int>, BFS(int)::<lambda(int, int)> >&)'
  456 |     class priority_queue
      |           ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:456:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/10/bits/stl_queue.h:456:11: note: candidate: 'std::priority_queue<int, std::vector<int>, BFS(int)::<lambda(int, int)> >::priority_queue(std::priority_queue<int, std::vector<int>, BFS(int)::<lambda(int, int)> >&&)'
/usr/include/c++/10/bits/stl_queue.h:456:11: note:   candidate expects 1 argument, 0 provided