Submission #433927

#TimeUsernameProblemLanguageResultExecution timeMemory
433927AmineWeslatiTraffickers (RMI18_traffickers)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll typedef vector<int>vi; #define pb push_back #define sz(x) (int)x.size() #define all(x) begin(x),end(x) typedef string str; typedef pair<int,int>pi; #define fi first #define se second typedef vector<pi>vpi; #define eb emplace_back #define FOR(i,a,b) for(int i=a; i<b; i++) #define ROF(i,a,b) for(int i=b-1; i>=a; i--) void ckmin(int &x, int y){x=min(x,y);} //------------------------------------ const int MX=1e5; int N; vi adj[MX]; multiset<pi> vec[MX]; vi par(MX); void dfs(int u, int p, int dest){ //if(u==dest) return; for(int v: adj[u]) if(v!=p){ par[v]=u; dfs(v,u,dest); } } void add(int u, int v){ dfs(u,u,v); int cur=v,n=0; vi cy; while(1){ n++; cy.pb(cur); if(cur==u) break; cur=par[cur]; } reverse(all(cy)); FOR(i,0,n){ vec[cy[i]].insert({n,i}); } } void del(int u, int v){ dfs(u,u,v); int cur=v,n=0; vi cy; while(1){ n++; cy.pb(cur); if(cur==u) break; cur=par[cur]; } reverse(all(cy)); FOR(i,0,n){ vec[cy[i]].erase(vec[cy[i]].find({n,i})); } } int32_t main(){ cin>>N; FOR(i,0,N-1){ int u,v; cin>>u>>v; adj[u].pb(v); adj[v].pb(u); } int K; cin>>K; FOR(i,0,K){ int u,v; cin>>u>>v; add(u,v); } /*FOR(i,1,N+1){ for(auto x: vec[i]) cout << x.fi << ' ' << x.se << endl; cout << endl; }*/ int Q; cin>>Q; while(Q--){ int ty; cin>>ty; if(ty==1){ int u,v; cin>>u>>v; add(u,v); } else if(ty==2){ int u,v; cin>>u>>v; del(u,v); } else{ int u,v,t,tt; cin>>u>>v>>t>>tt; dfs(u,u,v); int cur=v,ans=0; while(1){ for(auto it: vec[cur]){ int a=it.fi,b=it.se; int l=(t-b+a-1)/a,r=(tt-b)/a; ans+=max(0,r-l+1); } if(cur==u) break; cur=par[cur]; } cout << ans << endl; } } } /* 5 1 2 2 3 2 4 1 5 1 4 1 5 3 3 5 0 3 1 2 5 3 4 5 1 5 2 2 5 3 3 5 0 3 */

Compilation message (stderr)

traffickers.cpp: In function 'int32_t main()':
traffickers.cpp:120:22: error: no matching function for call to 'max(int, ll)'
  120 |      ans+=max(0,r-l+1);
      |                      ^
In file included 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 traffickers.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
traffickers.cpp:120:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  120 |      ans+=max(0,r-l+1);
      |                      ^
In file included 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 traffickers.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
traffickers.cpp:120:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  120 |      ans+=max(0,r-l+1);
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from traffickers.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
traffickers.cpp:120:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  120 |      ans+=max(0,r-l+1);
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from traffickers.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
traffickers.cpp:120:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  120 |      ans+=max(0,r-l+1);
      |                      ^