Submission #1104734

#TimeUsernameProblemLanguageResultExecution timeMemory
1104734sinataghizadehDynamic Diameter (CEOI19_diameter)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define all(x) (x).begin(),(x).end() #define pb push_back #define fi first #define se second #define beg begin #define siz size() #define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false); #define endl '\n' #define ins insert #define log LOG const ll inf = 1e9; const ll mod = 10289; const int maxn=5002; const int log=24; ll n,q,vis[maxn],dis[maxn],w,mx,a[maxn],seg[4*maxn]; void upd(ll a,ll b,ll l=0,ll r=n,ll id=1){ if(r-l==1){ seg[id]=b;return; } ll mid=(l+r)/2; if(a<mid)upd(a,b,l,mid,id*2); else upd(a,b,mid,r,id*2+1); seg[id]=seg[id*2]+seg[id*2+1]; } ll get(ll k,ll o=0,ll l=0,ll r=n,ll id=1){ if(r-l==1)return l; ll mid=(r+l)/2; if(o+seg[id*2]>k){ return get(k,o,l,mid,id*2); } else return get(k,o+seg[id*2],mid,r,id*2+1); } vector<int>adj[maxn]; map<pii,int>x; vector<pii>ed; void dfs(int v,int p){ for(auto u:adj[v]){ if(p==u)continue; dis[u]=dis[v]+x[{u,v}]; dfs(u,v); } if(dis[v]>dis[mx])mx=v; } int main(){ fastio cin>>n>>q>>w; for(int i=1;i<n;i++){ ll a1,b,c; cin>>a1>>b>>c; x[{a1,b}]=c; x[{b,a1}]=c; ed.pb({a1,b}); adj[a1].pb(b);adj[b].pb(a1); if(b>a)swap(a,b); a[a1]=c; } int ld=0; while(q--){ int d,e; cin>>d>>e;d+=ld;e+=ld;d%=(n-1);e%=w; int u=ed[d].fi,v=ed[d].se; x[{u,v}]=e;x[{v,u}]=e; if(v>u)swap(u,v); upd(v,e); ll mx1= } }

Compilation message (stderr)

diameter.cpp: In function 'int main()':
diameter.cpp:61:7: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   61 |   if(b>a)swap(a,b);
      |      ~^~
diameter.cpp:61:18: error: no matching function for call to 'swap(ll [5002], ll&)'
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:1:
/usr/include/c++/10/sstream:849:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>&)'
  849 |     swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/10/sstream:849:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:1:
/usr/include/c++/10/sstream:856:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>&)'
  856 |     swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/10/sstream:856:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:1:
/usr/include/c++/10/sstream:863:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>&)'
  863 |     swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/10/sstream:863:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:1:
/usr/include/c++/10/sstream:870:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>&)'
  870 |     swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/10/sstream:870:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/regex.h:849:5: note: candidate: 'template<class _Ch_type, class _Rx_traits> void std::__cxx11::swap(std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&)'
  849 |     swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
      |     ^~~~
/usr/include/c++/10/bits/regex.h:849:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::__cxx11::basic_regex<_Ch_type, _Rx_traits>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/regex.h:2141:5: note: candidate: 'template<class _Bi_iter, class _Alloc> void std::__cxx11::swap(std::__cxx11::match_results<_BiIter, _Alloc>&, std::__cxx11::match_results<_BiIter, _Alloc>&)'
 2141 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
/usr/include/c++/10/bits/regex.h:2141:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::__cxx11::match_results<_BiIter, _Alloc>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/bits/nested_exception.h:40,
                 from /usr/include/c++/10/exception:148,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/move.h:189:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/10/bits/move.h:189:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   deduced conflicting types for parameter '_Tp' ('long long int [5002]' and 'll' {aka 'long long int'})
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/bits/nested_exception.h:40,
                 from /usr/include/c++/10/exception:148,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/move.h:213:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<std::__is_swappable<_Tp>::value> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
  213 |     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
      |     ^~~~
/usr/include/c++/10/bits/move.h:213:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types '_Tp [_Nm]' and 'll' {aka 'long long int'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:533:5: note: candidate: 'template<class _T1, class _T2> void std::swap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&)'
  533 |     swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
      |     ^~~~
/usr/include/c++/10/bits/stl_pair.h:533:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::pair<_T1, _T2>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6420:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6420 |     swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~
/usr/include/c++/10/bits/basic_string.h:6420:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:68,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/stl_deque.h:2311:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(std::deque<_Tp, _Alloc>&, std::deque<_Tp, _Alloc>&)'
 2311 |     swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
      |     ^~~~
/usr/include/c++/10/bits/stl_deque.h:2311:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::deque<_Tp, _Alloc>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:70,
                 from diameter.cpp:1:
/usr/include/c++/10/fstream:1264:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_filebuf<_CharT, _Traits>&, std::basic_filebuf<_CharT, _Traits>&)'
 1264 |     swap(basic_filebuf<_CharT, _Traits>& __x,
      |     ^~~~
/usr/include/c++/10/fstream:1264:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::basic_filebuf<_CharT, _Traits>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:70,
                 from diameter.cpp:1:
/usr/include/c++/10/fstream:1271:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_ifstream<_CharT, _Traits>&, std::basic_ifstream<_CharT, _Traits>&)'
 1271 |     swap(basic_ifstream<_CharT, _Traits>& __x,
      |     ^~~~
/usr/include/c++/10/fstream:1271:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::basic_ifstream<_CharT, _Traits>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:70,
                 from diameter.cpp:1:
/usr/include/c++/10/fstream:1278:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_ofstream<_CharT, _Traits>&, std::basic_ofstream<_CharT, _Traits>&)'
 1278 |     swap(basic_ofstream<_CharT, _Traits>& __x,
      |     ^~~~
/usr/include/c++/10/fstream:1278:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::basic_ofstream<_CharT, _Traits>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:70,
                 from diameter.cpp:1:
/usr/include/c++/10/fstream:1285:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_fstream<_CharT, _Traits>&, std::basic_fstream<_CharT, _Traits>&)'
 1285 |     swap(basic_fstream<_CharT, _Traits>& __x,
      |     ^~~~
/usr/include/c++/10/fstream:1285:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::basic_fstream<_CharT, _Traits>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from diameter.cpp:1:
/usr/include/c++/10/array:321:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> void std::swap(std::array<_Tp, _Nm>&, std::array<_Tp, _Nm>&)'
  321 |     swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
      |     ^~~~
/usr/include/c++/10/array:321:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::array<_Tp, _Nm>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from diameter.cpp:1:
/usr/include/c++/10/tuple:1629:5: note: candidate: 'template<class ... _Elements> void std::swap(std::tuple<_Tps ...>&, std::tuple<_Tps ...>&)'
 1629 |     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
      |     ^~~~
/usr/include/c++/10/tuple:1629:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::tuple<_Tps ...>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/functional:59,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/std_function.h:720:5: note: candidate: 'template<class _Res, class ... _Args> void std::swap(std::function<_Res(_ArgTypes ...)>&, std::function<_Res(_ArgTypes ...)>&)'
  720 |     swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) noexcept
      |     ^~~~
/usr/include/c++/10/bits/std_function.h:720:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::function<_Res(_ArgTypes ...)>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/bits/locale_conv.h:41,
                 from /usr/include/c++/10/locale:43,
                 from /usr/include/c++/10/iomanip:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/unique_ptr.h:738:5: note: candidate: 'template<class _Tp, class _Dp> void std::swap(std::unique_ptr<_Tp, _Dp>&, std::unique_ptr<_Tp, _Dp>&)'
  738 |     swap(unique_ptr<_Tp, _Dp>& __x,
      |     ^~~~
/usr/include/c++/10/bits/unique_ptr.h:738:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::unique_ptr<_Tp, _Dp>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/list:63,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:79,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/stl_list.h:2082:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(std::__cxx11::list<_Tp, _Alloc>&, std::__cxx11::list<_Tp, _Alloc>&)'
 2082 |     swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
      |     ^~~~
/usr/include/c++/10/bits/stl_list.h:2082:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::__cxx11::list<_Tp, _Alloc>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/stl_tree.h:1655:5: note: candidate: 'template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> void std::swap(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)'
 1655 |     swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/10/bits/stl_tree.h:1655:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/stl_map.h:1537:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(std::map<_Key, _Tp, _Compare, _Alloc>&, std::map<_Key, _Tp, _Compare, _Alloc>&)'
 1537 |     swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/10/bits/stl_map.h:1537:5: note:   template argument deduction/substitution failed:
diameter.cpp:61:18: note:   mismatched types 'std::map<_Key, _Tp, _Compare, _Alloc>' and 'll [5002]' {aka 'long long int [5002]'}
   61 |   if(b>a)swap(a,b);
      |                  ^
In file included from /usr/include/c++/10/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from diameter.cpp:1:
/usr/include/c++/10/bits/stl_multimap.h:1202:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(std::multimap<_Key, _Tp, _Compare, _Alloc>&, std::multimap<_Key, _Tp, _Compare, _Alloc>&)'
 1202 |     swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/10/bits/stl_multimap.h:1202:5: note:   template argument deduction/substitution fail