Submission #248925

#TimeUsernameProblemLanguageResultExecution timeMemory
248925kostia244Ancient Books (IOI17_books)C++17
Compilation error
0 ms0 KiB
#include "books.h" #pragma GCC optimize("O2,unroll-loops") #pragma GCC target("avx,avx2,sse,sse2,ssse3") #include<bits/extc++.h> using namespace std; const int maxn = 1<<20; using ll = long long; using namespace __gnu_pbds; using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; ll vis[maxn][4]; ll minimum_walk(vector<int> p, int s) { oset pref, suf; vector<int> pos(p.size()); ll ans = 0, lst = -1, fi = -1; for(int i = 0; i < p.size(); i++) suf.insert(i), pos[p[i]] = i; for(int t, i = 0; i < p.size(); i++) { //cout << i << "::\n"; int v = p[i]; suf.erase(v); if(i != v) { vis[i][(v > i)*3]++; vis[i][1 + (pos[i]>i)]++; } t = pref.size()-pref.order_of_key(i+1); vis[i][1] += t, vis[i][3] += t; t = suf.order_of_key(i); vis[i][0] += t, vis[i][2] += t; pref.insert(v); if(vis[i][0] + vis[i][2] + vis[i][3] + vis[i][1]) { lst = i; if(fi == -1) fi = i; } //for(int j = 0; j < 4; j++) cout << vis[i][j] << " "; cout << endl; if(i) { assert(vis[i][0] == vis[i-1][2]); assert(vis[i][1] == vis[i-1][3]); } } fi = min(fi, s); for(int i = fi; i <= lst; i++) { for(int j = 0; j < 4; j++) { if(i == lst && j >= 2) break; if(i == fi && j < 2) continue; if(vis[i][j] == 0) { vis[i][j]++; vis[i + (j<2?-1:1)][j^3]++; } } } for(int i = 0; i < p.size(); i++) { //cout << vis[i][0] << " " << vis[i][1] << " " << vis[i][2] << " " << vis[i][3] << " " << g[i] << endl; vis[i][2] = vis[i][3] = max(vis[i][2], vis[i][3]); vis[i][0] = vis[i][1] = max(vis[i][0], vis[i][1]); ans += (vis[i][0] + vis[i][2]); } return ans; }

Compilation message (stderr)

books.cpp: In function 'll minimum_walk(std::vector<int>, int)':
books.cpp:17:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < p.size(); i++) suf.insert(i), pos[p[i]] = i;
                 ~~^~~~~~~~~~
books.cpp:18:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int t, i = 0; i < p.size(); i++) {
                    ~~^~~~~~~~~~
books.cpp:48:16: error: no matching function for call to 'min(ll&, int&)'
  fi = min(fi, s);
                ^
In file included from /usr/include/c++/7/vector:60:0,
                 from books.h:1,
                 from books.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
books.cpp:48:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  fi = min(fi, s);
                ^
In file included from /usr/include/c++/7/vector:60:0,
                 from books.h:1,
                 from books.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
books.cpp:48:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  fi = min(fi, s);
                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/extc++.h:32,
                 from books.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
books.cpp:48:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  fi = min(fi, s);
                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/extc++.h:32,
                 from books.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
books.cpp:48:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  fi = min(fi, s);
                ^
books.cpp:59:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < p.size(); i++) {
                 ~~^~~~~~~~~~