Submission #1159266

#TimeUsernameProblemLanguageResultExecution timeMemory
1159266AlgorithmWarriorPalembang Bridges (APIO15_bridge)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long long const INF=1e18; int const MAX=2e5+5; struct location{ int pos; char type; int id; bool operator<(location ot){ return pos<ot.pos; } }loc[MAX]; int k,n; long long s_init; int total_loc; struct interval{ int l,r,mij; }interv[MAX]; struct cmp{ bool operator()(int a,int b){ return interv[a].mij<interv[b].mij; } }; void read(){ cin>>k>>n; int i; for(i=1;i<=n;++i){ char t1,t2; int p1,p2; cin>>t1>>p1>>t2>>p2; s_init+=abs(p2-p1); if(t1!=t2){ loc[++total_loc]={p1,t1,i}; loc[++total_loc]={p2,t2,i}; ++s_init; } if(p1>p2) swap(p1,p2); interv[i]={p1,p2,(p1+p2)/2}; } sort(loc+1,loc+total_loc+1); } bool gasit_per[MAX]; void minself(long long&x,long long val){ if(x>val) x=val; } long long spate[MAX],fata[MAX]; void precalc(int inc,int fin,long long v[],int incr){ long long nr=0; int nrper=0; int i; for(i=inc;i!=fin+incr;i+=incr){ if(i!=inc) nr+=2LL*nrper*abs(loc[i-incr].pos-loc[i].pos); v[i]=nr; if(!gasit_per[loc[i].id]) gasit_per[loc[i].id]=1; else ++nrper; } for(i=1;i<=n;++i) gasit_per[i]=0; } long long solve1(){ long long rasp=INF; int i; for(i=1;i<=total_loc;++i) minself(rasp,spate[i]+fata[i]); return rasp; } set<int,cmp>inside; long long better(int st,int dr){ long long total=0; for(auto id : inside){ } } long long solve2(){ int st=1,dr; for(dr=1;dr<=total_loc;++dr){ if(!gasit_per[loc[dr].id]) gasit_per[loc[dr].id]=1; else inside.insert(loc[dr].id); while(st<dr); } } long long get_final_answer(){ if(!total_loc) return s_init; precalc(1,total_loc,spate,1); precalc(total_loc,1,fata,-1); if(k==1) return solve1()+s_init; } int main() { read(); cout<<get_final_answer(); return 0; }

Compilation message (stderr)

bridge.cpp: In function 'long long int better(int, int)':
bridge.cpp:89:1: warning: no return statement in function returning non-void [-Wreturn-type]
   89 | }
      | ^
bridge.cpp: In function 'long long int solve2()':
bridge.cpp:100:1: warning: no return statement in function returning non-void [-Wreturn-type]
  100 | }
      | ^
In file included from /usr/include/c++/11/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
                 from bridge.cpp:1:
/usr/include/c++/11/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = cmp; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<int>*]':
/usr/include/c++/11/bits/stl_tree.h:2071:47:   required from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = cmp; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = int]'
/usr/include/c++/11/bits/stl_tree.h:2124:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const int&; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = cmp; _Alloc = std::allocator<int>]'
/usr/include/c++/11/bits/stl_set.h:512:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = int; _Compare = cmp; _Alloc = std::allocator<int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, cmp, std::allocator<int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<int>, int>::rebind<int>; typename _Alloc::value_type = int; std::set<_Key, _Compare, _Alloc>::value_type = int]'
bridge.cpp:97:26:   required from here
/usr/include/c++/11/bits/stl_tree.h:770:15: error: static assertion failed: comparison object must be invocable as const
  770 |               is_invocable_v<const _Compare&, const _Key&, const _Key&>,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/stl_tree.h:770:15: note: 'std::is_invocable_v<const cmp&, const int&, const int&>' evaluates to false
bridge.cpp: In function 'long long int get_final_answer()':
bridge.cpp:110:1: warning: control reaches end of non-void function [-Wreturn-type]
  110 | }
      | ^