Submission #56040

#TimeUsernameProblemLanguageResultExecution timeMemory
56040KieranHorganShortcut (IOI16_shortcut)C++17
Compilation error
0 ms0 KiB
#include "shortcut.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define int long long ll prefix[3005]; ll bestB[3005]; ll bestA[3005]; long long find_shortcut(signed n, vector<signed> l, vector<signed> d, signed c) { vector<int> L = {0,0}; for(auto i: l) L.push_back(i); l=L; vector<int> D = {0}; for(auto i: d) D.push_back(i); d=D; for(int i = 1; i <= n; i++) prefix[i] = prefix[i-1] + l[i]; ll diam = 1ll<<50; vector<int> Db = D; for(int i = 1; i <= n; i++) Db[i] = max(Db[i], Db[i-1]+l[i]); vector<int> Da = D; for(int i = n-1; i >= 1; i--) Da[i] = max(Da[i], Da[i+1]+l[i+1]); // cerr << " "; // for(int i = 2; i <= n; i++) // cerr << l[i] << " "; // cerr << endl; // for(int i = 1; i <= n; i++) { // cerr << d[i] << " "; // if(d[i]==0) // cerr << " "; // } // cerr << endl; // cerr << endl; // // for(int i = 1; i <= n; i++) // cerr << Db[i] << " "; // cerr << endl; // cerr << endl; // for(int i = 1; i <= n; i++) // cerr << Da[i] << " "; // cerr << endl; // cerr << endl; for(int i = 1; i <= n; i++) for(int j = i+1; j <= n; j++) bestB[j] = max(bestB[j], prefix[j]-prefix[i] + d[i] + d[j]), bestA[i] = max(bestA[i], prefix[j]-prefix[i] + d[i] + d[j]); // for(int i = 1; i <= n; i++) // cerr << bestB[i] << " "; // cerr << endl; // for(int i = 1; i <= n; i++) // cerr << bestA[i] << " "; // cerr << endl; // cerr << endl; for(ll ci = 1; ci <= n; ci++) { for(ll cj = ci+1; cj <= n; cj++) { d[ci] = Db[ci]; d[cj] = Da[cj]; ll currDiam = max(bestB[ci], bestA[cj]); for(ll i = ci; i <= cj; i++){ for(ll j = i+1; j <= cj; j++) { currDiam = max(currDiam, min(prefix[j]-prefix[i] + d[i] + d[j], prefix[cj]-prefix[j] + c + prefix[i]-prefix[ci] + d[i] + d[j])); } } diam = min(diam, currDiam); d[ci] = D[ci]; d[cj] = D[cj]; } } return diam; }

Compilation message (stderr)

shortcut.cpp: In function 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:16:4: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<long long int>')
  l=L;
    ^
In file included from /usr/include/c++/7/vector:69:0,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/7/bits/vector.tcc:179:5: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/vector.tcc:179:5: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::vector<int>&'
In file included from /usr/include/c++/7/vector:64:0,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:461:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]
       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:461:7: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<int>&&'
/usr/include/c++/7/bits/stl_vector.h:482:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]
       operator=(initializer_list<value_type> __l)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::initializer_list<int>'
shortcut.cpp:19:4: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<long long int>')
  d=D;
    ^
In file included from /usr/include/c++/7/vector:69:0,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/7/bits/vector.tcc:179:5: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/vector.tcc:179:5: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::vector<int>&'
In file included from /usr/include/c++/7/vector:64:0,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:461:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]
       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:461:7: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<int>&&'
/usr/include/c++/7/bits/stl_vector.h:482:7: note: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]
       operator=(initializer_list<value_type> __l)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::initializer_list<int>'