답안 #537651

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
537651 2022-03-15T10:56:28 Z cig32 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
 
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
  int u = uniform_int_distribution<int>(x, y)(rng); return u;
}
 
struct node {
  int ans; // maximum sum inversion in range
  vector<int> v; // SORTED!!! crazy memory moment
} st[3*MAXN];
int n, m;
vector<int> v[MAXN];
void bu(int l, int r, int idx) {
  v[l].push_back(idx);
  st[idx].v.resize(r-l+1);
  if(l == r) {
    int w;
    cin >> w;
    st[idx].v[0] = w;
    st[idx].ans = -1;
    return;
  }
  int mid = (l + r) >> 1;
  bu(l, mid, 2*idx + 1);
  bu(mid+1, r, 2*idx + 2);
  int lptr = 0, rptr = 0;
  int nxt = 0;
  while(!(lptr == st[2*idx + 1].v.size() && rptr == st[2*idx + 2].v.size())) {
    if(lptr == st[2*idx+1].v.size()) {
      st[idx].v[nxt] = st[2*idx+2].v[rptr];
      rptr++;
      nxt++;
    }
    else if(rptr == st[2*idx+2].v.size()) {
      st[idx].v[nxt] = st[2*idx+1].v[lptr];
      lptr++;
      nxt++;
    }
    else {
      if(st[2*idx+1].v[lptr] < st[2*idx+2].v[rptr]) {
        st[idx].v[nxt] = st[2*idx+1].v[lptr];
        lptr++;
        nxt++;
      }
      else {
        st[idx].v[nxt] = st[2*idx+2].v[rptr];
        rptr++;
        nxt++;
      }
    }
  }
  st[idx].ans = max(st[2*idx+1].ans, st[2*idx+2].ans);
  int ma = st[2*idx+1].v[st[2*idx+1].v.size() - 1];
  int lb = 0, rb = st[2*idx+2].v.size() - 1;
  while(lb < rb) {
    int mid = (lb + rb + 1) >> 1;
    if(st[2*idx+2].v[mid] < ma) lb = mid;
    else rb = mid - 1;
  }
  if(st[2*idx+2].v[lb] < ma) {
    st[idx].ans = max(st[idx].ans, st[2*idx+2].v[lb] + ma);
  }
}
 
void build() {
  bu(1, n, 0);
}
 
int calc(int idx1) {
  return st[idx1].v.size() - 1;
}
bool cmp(int a, int b) {
  return calc(a) < calc(b);
}
void solve(int tc) {
  int n = 1000000;
  set<int> v(n);
  for(int i=0; i<n; i++) v.insert(i);
  int j = 0;
  for(int i=0; i<10000000; i++) {
    auto it = v.lower_bound(j);
    j = (j == n-1 ? 0 : j+1);
  }
}
int32_t main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int t = 1; //cin >> t;
  for(int i=1; i<=t; i++) solve(i);
}

Compilation message

sortbooks.cpp: In function 'void bu(int, int, int)':
sortbooks.cpp:32:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   while(!(lptr == st[2*idx + 1].v.size() && rptr == st[2*idx + 2].v.size())) {
      |           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:32:50: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   while(!(lptr == st[2*idx + 1].v.size() && rptr == st[2*idx + 2].v.size())) {
      |                                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:33:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     if(lptr == st[2*idx+1].v.size()) {
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     else if(rptr == st[2*idx+2].v.size()) {
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp: In function 'void solve(int)':
sortbooks.cpp:81:15: error: no matching function for call to 'std::set<int>::set(int&)'
   81 |   set<int> v(n);
      |               ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from sortbooks.cpp:1:
/usr/include/c++/10/bits/stl_set.h:271:2: note: candidate: 'template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  271 |  set(_InputIterator __first, _InputIterator __last,
      |  ^~~
/usr/include/c++/10/bits/stl_set.h:271:2: note:   template argument deduction/substitution failed:
sortbooks.cpp:81:15: note:   candidate expects 3 arguments, 1 provided
   81 |   set<int> v(n);
      |               ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from sortbooks.cpp:1:
/usr/include/c++/10/bits/stl_set.h:265:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(std::initializer_list<_Tp>, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  265 |       set(initializer_list<value_type> __l, const allocator_type& __a)
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:265:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_set.h:259:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(std::set<_Key, _Compare, _Alloc>&&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  259 |       set(set&& __x, const allocator_type& __a)
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:259:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_set.h:255:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(const std::set<_Key, _Compare, _Alloc>&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  255 |       set(const set& __x, const allocator_type& __a)
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:255:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_set.h:251:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  251 |       set(const allocator_type& __a)
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:251:33: note:   no known conversion for argument 1 from 'int' to 'const allocator_type&' {aka 'const std::allocator<int>&'}
  251 |       set(const allocator_type& __a)
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:243:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(std::initializer_list<_Tp>, const _Compare&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  243 |       set(initializer_list<value_type> __l,
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:243:40: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
  243 |       set(initializer_list<value_type> __l,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:231:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(std::set<_Key, _Compare, _Alloc>&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  231 |       set(set&&) = default;
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:231:11: note:   no known conversion for argument 1 from 'int' to 'std::set<int>&&'
  231 |       set(set&&) = default;
      |           ^~~~~
/usr/include/c++/10/bits/stl_set.h:223:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(const std::set<_Key, _Compare, _Alloc>&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  223 |       set(const set&) = default;
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:223:11: note:   no known conversion for argument 1 from 'int' to 'const std::set<int>&'
  223 |       set(const set&) = default;
      |           ^~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:208:2: note: candidate: 'template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator, const _Compare&, const allocator_type&) [with _InputIterator = _InputIterator; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  208 |  set(_InputIterator __first, _InputIterator __last,
      |  ^~~
/usr/include/c++/10/bits/stl_set.h:208:2: note:   template argument deduction/substitution failed:
sortbooks.cpp:81:15: note:   candidate expects 4 arguments, 1 provided
   81 |   set<int> v(n);
      |               ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from sortbooks.cpp:1:
/usr/include/c++/10/bits/stl_set.h:191:2: note: candidate: 'template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  191 |  set(_InputIterator __first, _InputIterator __last)
      |  ^~~
/usr/include/c++/10/bits/stl_set.h:191:2: note:   template argument deduction/substitution failed:
sortbooks.cpp:81:15: note:   candidate expects 2 arguments, 1 provided
   81 |   set<int> v(n);
      |               ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from sortbooks.cpp:1:
/usr/include/c++/10/bits/stl_set.h:176:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(const _Compare&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  176 |       set(const _Compare& __comp,
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:176:27: note:   no known conversion for argument 1 from 'int' to 'const std::less<int>&'
  176 |       set(const _Compare& __comp,
      |           ~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/10/bits/stl_set.h:167:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set() [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  167 |       set() = default;
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:167:7: note:   candidate expects 0 arguments, 1 provided