Submission #430936

#TimeUsernameProblemLanguageResultExecution timeMemory
430936Emin2004Boxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define endl '\n' #define pii pair <int, int> #define pb push_back #define F first #define S second #define ll long long #define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define M_PI 3.14159265358979323846 const int N = 200005; const int mod = 1e9 + 7; vector<ll> a[N]; ll used[N], m, o, z; ll ans = 0, res = LONG_MAX; void DFS(int node, int rem, int vis){ used[node] = 1; ll cur = ans; if(vis == z){ ans += min(node, m - node); res = min(res, ans); } else{ ans += min(node, m - node); if(node != m) DFS(m, o, vis); if(rem == 0) { ans = cur; used[node] = 0; return; } for(int i : a[node]){ if(!used[i]){ ans = cur + min(abs(node - i), m - abs(node - i)); DFS(i, rem - 1, vis + 1); } } } ans = cur; used[node] = 0; } long long delivery(int n, int k, int l, int p[]) { m = l; o = k; z = n; for(int i = 0; i < n; i++){ a[m].pb(p[i]); for(int j = i + 1; j < n; j++){ int x = p[i]; int y = p[j]; a[x].pb(y); a[y].pb(x); } } DFS(m, k, 0); return res; }

Compilation message (stderr)

boxes.cpp: In function 'void DFS(int, int, int)':
boxes.cpp:25:34: error: no matching function for call to 'min(int&, long long int)'
   25 |         ans += min(node, m - node);
      |                                  ^
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 boxes.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   25 |         ans += min(node, m - node);
      |                                  ^
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 boxes.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   25 |         ans += min(node, m - node);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |         ans += min(node, m - node);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |         ans += min(node, m - node);
      |                                  ^
boxes.cpp:29:34: error: no matching function for call to 'min(int&, long long int)'
   29 |         ans += min(node, m - node);
      |                                  ^
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 boxes.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   29 |         ans += min(node, m - node);
      |                                  ^
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 boxes.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   29 |         ans += min(node, m - node);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |         ans += min(node, m - node);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |         ans += min(node, m - node);
      |                                  ^
boxes.cpp:30:27: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   30 |         if(node != m) DFS(m, o, vis);
      |                           ^
boxes.cpp:30:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   30 |         if(node != m) DFS(m, o, vis);
      |                              ^
boxes.cpp:36:27: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   36 |         for(int i : a[node]){
      |                           ^
boxes.cpp:38:65: error: no matching function for call to 'min(int, long long int)'
   38 |                 ans = cur + min(abs(node - i), m - abs(node - i));
      |                                                                 ^
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 boxes.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:38:65: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   38 |                 ans = cur + min(abs(node - i), m - abs(node - i));
      |                                                                 ^
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 boxes.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:38:65: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   38 |                 ans = cur + min(abs(node - i), m - abs(node - i));
      |                                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
boxes.cpp:38:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |                 ans = cur + min(abs(node - i), m - abs(node - i));
      |                                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
boxes.cpp:38:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |                 ans = cur + min(abs(node - i), m - abs(node - i));
      |                                                                 ^
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:60:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   60 |     DFS(m, k, 0);
      |         ^