Submission #131767

#TimeUsernameProblemLanguageResultExecution timeMemory
131767amiratouWiring (IOI17_wiring)C++14
20 / 100
41 ms5376 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; #define ll long long vector<int> A,B; int dp[201][201]; int solve(int i,int j){ if(i==A.size()&&j==B.size())return 0; if(i==A.size()||j==B.size())return INT_MAX; if(dp[i][j]!=-1)return dp[i][j]; return dp[i][j]=abs(A[i]-B[j])+min(solve(i+1,j+1),min(solve(i+1,j),solve(i,j+1))); } ll min_total_length(vector<int> r,vector<int> b) { if(b[0]>r[r.size()-1]){ ll ans=0; if(r.size()>b.size()){ for (int i = 0; i < b.size(); ++i) ans+=(b[i]-r[r.size()-i-1]); for (int i = r.size()-b.size()-1; i >=0 ; i--) ans+=b[0]-r[i]; } else{ for (int i = 0; i < r.size(); ++i) ans+=b[i]-r[i]; for (int i = r.size(); i < b.size(); ++i) ans+=b[i]-r[r.size()-1]; } return ans; } A=r,B=b; memset(dp,-1,sizeof dp); return solve(0,0); }

Compilation message (stderr)

wiring.cpp: In function 'int solve(int, int)':
wiring.cpp:8:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(i==A.size()&&j==B.size())return 0;
     ~^~~~~~~~~~
wiring.cpp:8:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(i==A.size()&&j==B.size())return 0;
                  ~^~~~~~~~~~
wiring.cpp:9:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(i==A.size()||j==B.size())return INT_MAX; 
     ~^~~~~~~~~~
wiring.cpp:9:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(i==A.size()||j==B.size())return INT_MAX; 
                  ~^~~~~~~~~~
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:17:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int i = 0; i < b.size(); ++i)
                    ~~^~~~~~~~~~
wiring.cpp:23:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int i = 0; i < r.size(); ++i)
                    ~~^~~~~~~~~~
wiring.cpp:25:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int i = r.size(); i < b.size(); ++i)
                           ~~^~~~~~~~~~
#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...