Submission #1112421

#TimeUsernameProblemLanguageResultExecution timeMemory
1112421n3rm1nEvent Hopping (BOI22_events)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } struct pus { int s, e, index; pus(){}; pus(int _s, int _e, int _index) { s = _s; e = _e; index = _index; } }; int n, q; int s[MAXN], e[MAXN], maxt = 0; unordered_map < int, int > mp; vector < int > p; int t[MAXN * 4]; void make_tree(int i, int l, int r) { t[i] = 1e9; if(l == r)return; int mid = (l + r)/2; make_tree(2*i, l, mid); make_tree(2*i+1, mid+1, r); } int val, x; void update(int i, int l, int r) { if(l == r) { t[i] = min(t[i], val); return; } int mid = (l + r)/2; if(x <= mid)update(2*i, l, mid); else update(2*i+1, mid+1, r); t[i] = min(t[2*i], t[2*i+1]); } int ql, qr; int query(int i, int l, int r) { if(qr < l || ql > r)return 1e9; if(ql <= l && r <= qr)return t[i]; int mid = (l + r)/2; return min(query(2*i, l, mid), query(2*i+1, mid+1, r)); } void read() { cin >> n >> q; vector < int > g; for (int i = 1; i <= n; ++ i) { cin >> s[i] >> e[i]; g.push_back(s[i]); g.push_back(e[i]); } sort(g.begin(), g.end()); int last = -1; for (auto x: g) { if(last == x)continue; maxt ++; mp[x] = maxt; last = x; } for (int i = 1; i <= n; ++ i) { s[i] = mp[s[i]]; t[i] = mp[t[i]]; p.push_back(pus(s[i], e[i], i)); } sort(p.begin(), p.end(), cmp); } void solve() { for (auto &[s, e, i]: p) { } } int main() { speed(); read(); return 0; }

Compilation message (stderr)

events.cpp: In function 'void read()':
events.cpp:82:39: error: no matching function for call to 'std::vector<int>::push_back(pus)'
   82 |         p.push_back(pus(s[i], e[i], i));
      |                                       ^
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 events.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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = 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 'pus' to 'const value_type&' {aka 'const 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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = 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 'pus' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
events.cpp:84:30: error: 'cmp' was not declared in this scope; did you mean 'mp'?
   84 |     sort(p.begin(), p.end(), cmp);
      |                              ^~~
      |                              mp
events.cpp: In function 'void solve()':
events.cpp:89:16: error: cannot decompose non-array non-class type 'int'
   89 |     for (auto &[s, e, i]: p)
      |                ^~~~~~~~~
events.cpp:89:16: warning: unused structured binding declaration [-Wunused-variable]