Submission #670351

#TimeUsernameProblemLanguageResultExecution timeMemory
670351einpyWiring (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair long long min_total_length(std::vector<int> r, std::vector<int> b){ vector<pair<ll,ll>> pts; for (int x : r){ pts.emplace_back(x, 1); } for (int x : b){ pts.emplace_back(x,0); } sort(all(pts)); vector<ll> nextDiffColorDown(pts.size()); nextDiffColorWord.back() = -1; for (ll i = (ll)pts.size() - 2; i >= 0; i--){ if (pts[i].second != pts[i + 1].second){ nextDiffCOlorUp[i] = i + 1; }else{ nextDiffColorUp[i] = nextDiffColorUp[i+1]; } } vector<ll> nextDiffColorUp(pts.size()); nextDiffColorUp(pts.size()); for (ll i = 1; i < (ll) pts.size(); i ++){ if (pts[i].second != pts[i-1].second){ nextDiffColorUp[i] = i - 1; }else{ nextDiffColorUp[i] = nextDiffColorUp[i-1]; } } vector<ll> sumDown(pts.size(), 0); for (ll i = 1; i < (ll)pts.size(); i++){ if (pts[i].second != pts[i-1].second){ sumDown[i] = 0; }else if(nextDiffColorDown[i] == -1){ sumDown[i] = 1E9; } else{ ll dest = nextDiffColorDown[i] + 1; sumDown[i] = sumDown[i - 1] + (pts[i].first - pts[dest].first); } } vector<ll> sumUp(pts.size(), 0); for (ll i = (ll)pts.size() - 2; i >= 0, i--){ if (pts[i].second != pts[i + 1].second){ sumUp[i] = pts[i + 1].first pts[i].first; } else if (nextDiffColorUp[i] == -1){ sumUp[i] = 1E9; }else{ ll dest = nextDiffColorUp[i]; sumUp[i] = sumUp[i+1] + (pts[dest].first - pts[i].first); } } vector<ll> dp(pts.size() + 1, 0){ for (ll i = (ll)pts.size() - 1; i >= 0; i--){ ll ans = LLONG_MAX; if (nextDiffColorDown[i] != -1){ ans = dp[i+1] + (pts[i].first - pts[nextDiffColorDown[i]].first); } if (nextDiffColorUp[i] != -1){ ll lenNextSegmentPlus1 = NextDiffColorUp[NextDiffColorUp[i]] - 1; if (nextSegmentEndPlus1 == -1){ nextSegmentEndPlus1 = pts.size(); } ll lenNextSegment = nextSEgmentEndPlus1 - nextDiffColorUp[i]; ll maxL = min( nextDiffColorUp[i] - i, lenNextSegment ); for (ll L = 1; L <maxL; L++){ ans = min(ans, dp[nextDiffColorUp[i] + L] + sumUp[i] + sumDown[nextDiffColorUp[i] + L - 1]) } } dp[i] = ans; } } }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:15:10: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   15 |     sort(all(pts));
      |          ^~~
      |          std::filesystem::perms::all
In file included from /usr/include/c++/10/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/fs_fwd.h:148:7: note: 'std::filesystem::perms::all' declared here
  148 |       all  =  0777,
      |       ^~~
wiring.cpp:17:5: error: 'nextDiffColorWord' was not declared in this scope; did you mean 'nextDiffColorDown'?
   17 |     nextDiffColorWord.back() = -1;
      |     ^~~~~~~~~~~~~~~~~
      |     nextDiffColorDown
wiring.cpp:20:13: error: 'nextDiffCOlorUp' was not declared in this scope; did you mean 'nextDiffColorDown'?
   20 |             nextDiffCOlorUp[i] = i + 1;
      |             ^~~~~~~~~~~~~~~
      |             nextDiffColorDown
wiring.cpp:22:13: error: 'nextDiffColorUp' was not declared in this scope; did you mean 'nextDiffColorDown'?
   22 |             nextDiffColorUp[i] = nextDiffColorUp[i+1];
      |             ^~~~~~~~~~~~~~~
      |             nextDiffColorDown
wiring.cpp:27:31: error: no match for call to '(std::vector<long long int>) (std::vector<std::pair<long long int, long long int> >::size_type)'
   27 |     nextDiffColorUp(pts.size());
      |                               ^
wiring.cpp:50:39: warning: left operand of comma operator has no effect [-Wunused-value]
   50 |     for (ll i = (ll)pts.size() - 2; i >= 0, i--){
      |                                     ~~^~~~
wiring.cpp:50:48: error: expected ';' before ')' token
   50 |     for (ll i = (ll)pts.size() - 2; i >= 0, i--){
      |                                                ^
      |                                                ;
wiring.cpp:52:40: error: expected ';' before 'pts'
   52 |             sumUp[i] = pts[i + 1].first  pts[i].first;
      |                                        ^ ~~~
      |                                        ;
wiring.cpp:61:37: error: expected ',' or ';' before '{' token
   61 |     vector<ll> dp(pts.size() + 1, 0){
      |                                     ^
wiring.cpp:87:1: warning: no return statement in function returning non-void [-Wreturn-type]
   87 | }
      | ^