Submission #390784

#TimeUsernameProblemLanguageResultExecution timeMemory
390784alishahali1382Wiring (IOI17_wiring)C++14
0 / 100
2 ms2128 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; #define debug(x) {cerr<<#x<<"="<<x<<"\n";} #define debug2(x, y) {cerr<<#x<<", "<<#y<<" = "<<x<<", "<<y<<"\n";} #define pb push_back #define all(x) x.begin(), x.end() const int inf=1000000100; const int MAXN=100010; int n, m, k; ll dp[205][205]; ll X[MAXN], Y[MAXN]; ll min_total_length(vector<int> R, vector<int> B){ memset(dp, 63, sizeof(dp)); memset(X, 63, sizeof(X)); memset(Y, 63, sizeof(Y)); for (int i=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){ ll d=abs(R[i-1]-B[j-1]); X[i]=min(X[i], d); Y[i]=min(Y[i], d); } dp[0][0]=0; for (int i=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){ ll d=abs(R[i-1]-B[j-1]); // dp[i][j]=min({dp[i-1][j], dp[i][j-1], dp[i-1][j-1]}) + d; dp[i][j]=min(dp[i-1][j]+X[i], dp[i][j-1]+Y[j]); dp[i][j]=min(dp[i][j], dp[i-1][j-1]+d); } return dp[R.size()][B.size()]; }

Compilation message (stderr)

wiring.cpp: In function 'll min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for (int i=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){
      |                ~^~~~~~~~~~
wiring.cpp:24:49: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for (int i=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){
      |                                                ~^~~~~~~~~~
wiring.cpp:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){
      |                ~^~~~~~~~~~
wiring.cpp:30:49: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){
      |                                                ~^~~~~~~~~~
#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...