Submission #828393

#TimeUsernameProblemLanguageResultExecution timeMemory
828393tolbiAncient Books (IOI17_books)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "books.h" long long minimum_walk(std::vector<int> p, int s) { return solve(p,s,false)+solve int n = p.size(); vector<bool> vis(n,false); vector<pair<int,int>> hehe; for (int i = 0; i < n; i++){ if (vis[i]) continue; int node = i; if (p[node]==node) continue; while (!vis[node]){ vis[node]=true; hehe.push_back({min(node,p[node]),1}); hehe.push_back({max(node,p[node]),-1}); node=p[node]; } } sort(hehe.begin(), hehe.end()); long long ans = 0; int crr = 0; int indi = 0; for (int i = s; i < n-1; i++){ while (indi<hehe.size() && hehe[indi].first<=i){ crr+=hehe[indi].second; indi++; } if (indi!=hehe.size() && crr==0){ ans+=2; } if (crr>0) ans+=crr; } sort(hehe.rbegin(), hehe.rend()); crr = 0; indi = 0; for (int i = s; i >= 0; i--){ while (indi<hehe.size() && hehe[indi].first>=i){ crr-=hehe[indi].second; indi++; } if (indi!=hehe.size() && crr==0){ ans+=2; } if (crr>0) ans+=crr; } return ans; }

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:5:9: error: 'solve' was not declared in this scope
    5 |  return solve(p,s,false)+solve
      |         ^~~~~
books.cpp:5:31: error: expected ';' before 'int'
    5 |  return solve(p,s,false)+solve
      |                               ^
      |                               ;
    6 |  int n = p.size();
      |  ~~~                           
books.cpp:25:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   while (indi<hehe.size() && hehe[indi].first<=i){
      |          ~~~~^~~~~~~~~~~~
books.cpp:29:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   if (indi!=hehe.size() && crr==0){
      |       ~~~~^~~~~~~~~~~~~
books.cpp:39:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   while (indi<hehe.size() && hehe[indi].first>=i){
      |          ~~~~^~~~~~~~~~~~
books.cpp:43:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   if (indi!=hehe.size() && crr==0){
      |       ~~~~^~~~~~~~~~~~~