Submission #71398

#TimeUsernameProblemLanguageResultExecution timeMemory
71398KmcodeWiring (IOI17_wiring)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> //#include "books.h" using namespace std; #define MAX 100002 int n; long long int dp[MAX][60]; long long min_total_length(std::vector<int> r, std::vector<int> b) { for(int i=0;i<r.size();i++) for(int j=0;j<60;j++){ dp[i][j]=LLONG_MAX; } } dp[0][20]=abs(r[0]-b[0]); for(int i=0;i<r.size();i++){ for(int j1=0;j1<50;j1++){ int j=i+j1-20; if(j<0||j>=b.size())continue; if(dp[i][j1]==LLONG_MAX)continue; if(i+1<r.size()){ int base=i+1-20; dp[i+1][j-base]=min(dp[i+1][j-base],dp[i][j1]+abs(r[i+1]-b[j])); } if(j+1<b.size()){ int base=i-20; dp[i][j+1-base]=min(dp[i][j+1-base],dp[i][j1]+abs(r[i]-b[j+1])); } if(i+1<r.size()&&j+1<b.size()){ int base=i+1-20; dp[i+1][j+1-base]=min(dp[i+1][j+1-base],dp[i][j1]+abs(r[i+1]-b[j+1])); } } } int t=r.size()-1; return dp[r.size()-1][(int)b.size()-1-(t)+20]; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:9:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<r.size();i++)
              ~^~~~~~~~~
wiring.cpp:13:2: warning: no return statement in function returning non-void [-Wreturn-type]
  }
  ^
wiring.cpp: At global scope:
wiring.cpp:14:2: error: 'dp' does not name a type
  dp[0][20]=abs(r[0]-b[0]);
  ^~
wiring.cpp:15:2: error: expected unqualified-id before 'for'
  for(int i=0;i<r.size();i++){
  ^~~
wiring.cpp:15:14: error: 'i' does not name a type
  for(int i=0;i<r.size();i++){
              ^
wiring.cpp:15:25: error: 'i' does not name a type
  for(int i=0;i<r.size();i++){
                         ^
wiring.cpp:34:8: error: 'r' was not declared in this scope
  int t=r.size()-1;
        ^
wiring.cpp:35:2: error: expected unqualified-id before 'return'
  return dp[r.size()-1][(int)b.size()-1-(t)+20];
  ^~~~~~
wiring.cpp:36:1: error: expected declaration before '}' token
 }
 ^