Submission #391635

# Submission time Handle Problem Language Result Execution time Memory
391635 2021-04-19T12:56:34 Z apostoldaniel854 Examination (JOI19_examination) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef
tree<
  pair<int,int>,
  null_type,
  less<pair<int,int>>,
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;


using ll = long long;
#define dbg(x) cerr << #x << " " << x << "\n"

const int UPDATE = 1, QUERY = 2;

struct event_t {
    int total;
    int math;
    int info;
    int id;
    int type;
    bool operator < (const event_t &other) const {
        if (total != other.total)
            return total < other.total;
        return type < other.type;
    }
};

class fenwick2d {
    int n;
    std::vector <ordered_set> aib;
    fenwick2d (int n) {
        this->n = n;
        aib.resize (1 + n);
    }
    void update (int x, int y) {
        while (x <= n) {
            aib[x].insert (y);
            x += x & -x;
        }
    }
    int query (int x, int y) {
        int ans = 0;
        while (x > 0) {
            ans += aib[x].order_of_key (y);
            x -= x & -x;
        }
        return ans;
    }
};

int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);
    int n, q;
    map <int, int> norm;
    cin >> n >> q;
    vector <event_t> events;
    for (int i = 1; i <= n; i++) {
        int x, y;
        cin >> x >> y;
        events.push_back ({x + y, x, y, i, UPDATE});
        norm[x];
    }
    for (int i = 1; i <= q; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        events.push_back ({z, x, y, i, QUERY});
        norm[x];
    }
    int tag = 0;
    for (auto &x : norm)
        x.second = ++tag;
    sort (events.begin (), events.end ());
    fenwick2d table (tag);
    for (event_t event : events) {
        if (event.type == UPDATE) {
            table.update (event.x, event.y);
        }
        else {
            sol[event.id] = table.query (event.x, event.y);
        }
    }
    for (int i = 1; i <= q; i++)
        cout << sol[i] << "\n";
    return 0;
}

Compilation message

examination.cpp: In member function 'void fenwick2d::update(int, int)':
examination.cpp:45:28: error: cannot convert 'int' to '__gnu_pbds::detail::rb_tree_set<std::pair<int, int>, __gnu_pbds::null_type, std::less<std::pair<int, int> >, __gnu_pbds::detail::tree_traits<std::pair<int, int>, __gnu_pbds::null_type, std::less<std::pair<int, int> >, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::const_reference' {aka 'const std::pair<int, int>&'}
   45 |             aib[x].insert (y);
      |                            ^
      |                            |
      |                            int
In file included from /usr/include/c++/9/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp:235,
                 from /usr/include/c++/9/ext/pb_ds/detail/container_base_dispatch.hpp:85,
                 from /usr/include/c++/9/ext/pb_ds/assoc_container.hpp:48,
                 from examination.cpp:3:
/usr/include/c++/9/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp:44:24: note:   initializing argument 1 of 'std::pair<typename __gnu_pbds::detail::bin_search_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::point_iterator, bool> __gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::insert(__gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::const_reference) [with Key = std::pair<int, int>; Mapped = __gnu_pbds::null_type; Cmp_Fn = std::less<std::pair<int, int> >; Node_And_It_Traits = __gnu_pbds::detail::tree_traits<std::pair<int, int>, __gnu_pbds::null_type, std::less<std::pair<int, int> >, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >; _Alloc = std::allocator<char>; typename __gnu_pbds::detail::bin_search_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::point_iterator = __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >; __gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::const_reference = const std::pair<int, int>&]'
   44 | insert(const_reference r_value)
      |        ~~~~~~~~~~~~~~~~^~~~~~~
examination.cpp: In member function 'int fenwick2d::query(int, int)':
examination.cpp:52:41: error: cannot convert 'int' to '__gnu_pbds::tree_order_statistics_node_update<__gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, std::allocator<char> >, std::less<std::pair<int, int> >, std::allocator<char> >::key_const_reference' {aka 'const std::pair<int, int>&'}
   52 |             ans += aib[x].order_of_key (y);
      |                                         ^
      |                                         |
      |                                         int
In file included from /usr/include/c++/9/ext/pb_ds/tree_policy.hpp:149,
                 from /usr/include/c++/9/ext/pb_ds/detail/standard_policies.hpp:48,
                 from /usr/include/c++/9/ext/pb_ds/assoc_container.hpp:47,
                 from examination.cpp:3:
/usr/include/c++/9/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp:77:34: note:   initializing argument 1 of '__gnu_pbds::tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>::size_type __gnu_pbds::tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>::order_of_key(__gnu_pbds::tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>::key_const_reference) const [with Node_CItr = __gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, std::allocator<char> >; Node_Itr = __gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, std::allocator<char> >; Cmp_Fn = std::less<std::pair<int, int> >; _Alloc = std::allocator<char>; __gnu_pbds::tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>::size_type = long unsigned int; __gnu_pbds::tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>::key_const_reference = const std::pair<int, int>&]'
   77 | order_of_key(key_const_reference r_key) const
      |              ~~~~~~~~~~~~~~~~~~~~^~~~~
examination.cpp: In function 'int main()':
examination.cpp:82:25: error: 'fenwick2d::fenwick2d(int)' is private within this context
   82 |     fenwick2d table (tag);
      |                         ^
examination.cpp:39:5: note: declared private here
   39 |     fenwick2d (int n) {
      |     ^~~~~~~~~
examination.cpp:85:33: error: 'struct event_t' has no member named 'x'
   85 |             table.update (event.x, event.y);
      |                                 ^
examination.cpp:85:42: error: 'struct event_t' has no member named 'y'
   85 |             table.update (event.x, event.y);
      |                                          ^
examination.cpp:88:13: error: 'sol' was not declared in this scope
   88 |             sol[event.id] = table.query (event.x, event.y);
      |             ^~~
examination.cpp:88:48: error: 'struct event_t' has no member named 'x'
   88 |             sol[event.id] = table.query (event.x, event.y);
      |                                                ^
examination.cpp:88:57: error: 'struct event_t' has no member named 'y'
   88 |             sol[event.id] = table.query (event.x, event.y);
      |                                                         ^
examination.cpp:92:17: error: 'sol' was not declared in this scope
   92 |         cout << sol[i] << "\n";
      |                 ^~~