Submission #778573

#TimeUsernameProblemLanguageResultExecution timeMemory
778573I_Love_EliskaM_Wiring (IOI17_wiring)C++14
13 / 100
22 ms4556 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; #define forn(i,n) for(int i=0;i<n;++i) #define pb push_back #define ll long long ll zzz(vector<int> r, vector<int> b) { int n=min(r.size(),b.size()); ll ans=0; forn(i,n) ans+=b[i]-r[i]; if (r.size()>n) for (int i=n; i<r.size(); ++i) ans+=b[0]-r[i]; if (b.size()>n) for (int i=n; i<b.size(); ++i) ans+=b[i]-r[n-1]; return ans; } ll min_total_length(vector<int> r, vector<int> b) { if (r.back()<b[0]) return zzz(r,b); if (r.back()>b.back()) swap(r,b); ll ans=0; int n=r.size(),m=b.size(); if (max(r.back(),b.back())<=n+m) { r.pb(1e9), b.pb(1e9); queue<int> f,s; for(auto&x:r) f.push(x); for(auto&x:b) s.push(x); int i=0, j=0; for (int x=1; x<=n+m; ++x) { if (r[i]==x) { ++i; if (f.front()>x) continue; f.pop(); if (s.front()==1e9) { ans+=x-b[m-1]; continue; } auto y=s.front(); s.pop(); ans+=y-x; } else { if (s.front()>x) continue; s.pop(); if (f.front()==1e9) { ans+=x-r[n-1]; continue; } auto y=f.front(); f.pop(); ans+=y-x; } } return ans; } return 0; }

Compilation message (stderr)

wiring.cpp: In function 'long long int zzz(std::vector<int>, std::vector<int>)':
wiring.cpp:12:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |  if (r.size()>n) for (int i=n; i<r.size(); ++i) ans+=b[0]-r[i];
      |      ~~~~~~~~^~
wiring.cpp:12:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  if (r.size()>n) for (int i=n; i<r.size(); ++i) ans+=b[0]-r[i];
      |                                ~^~~~~~~~~
wiring.cpp:13:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |  if (b.size()>n) for (int i=n; i<b.size(); ++i) ans+=b[i]-r[n-1];
      |      ~~~~~~~~^~
wiring.cpp:13:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  if (b.size()>n) for (int i=n; i<b.size(); ++i) ans+=b[i]-r[n-1];
      |                                ~^~~~~~~~~
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:32:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   32 |     if (f.front()>x) continue; f.pop();
      |     ^~
wiring.cpp:32:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   32 |     if (f.front()>x) continue; f.pop();
      |                                ^
wiring.cpp:39:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   39 |     if (s.front()>x) continue; s.pop();
      |     ^~
wiring.cpp:39:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   39 |     if (s.front()>x) continue; s.pop();
      |                                ^
wiring.cpp:28:12: warning: unused variable 'j' [-Wunused-variable]
   28 |   int i=0, j=0;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...