Submission #597147

#TimeUsernameProblemLanguageResultExecution timeMemory
597147Ahmadsm2005Wiring (IOI17_wiring)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" //#include "grader.cpp" using namespace std; long long min_total_length(std::vector<int> r, std::vector<int> b) { if(b.size()>r.size()){ long long ANS=0; for(int i=0;i<b.size();i++){ ANS+=abs(b[i]-r[min((int)r.size()-1,i)]); } else{ int z=b.size()-1; for(int i=r.size()-1;i>=0;i--){ ANS+=abs(r[i]-b[max(z,0)]); z--; } } } return ANS; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:7:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | for(int i=0;i<b.size();i++){
      |             ~^~~~~~~~~
wiring.cpp:10:1: error: expected '}' before 'else'
   10 | else{
      | ^~~~
wiring.cpp:5:22: note: to match this '{'
    5 | if(b.size()>r.size()){
      |                      ^
wiring.cpp:13:1: error: 'ANS' was not declared in this scope
   13 | ANS+=abs(r[i]-b[max(z,0)]);
      | ^~~
wiring.cpp:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
   17 | }
      | ^
wiring.cpp: At global scope:
wiring.cpp:18:1: error: expected unqualified-id before 'return'
   18 | return ANS;
      | ^~~~~~
wiring.cpp:19:1: error: expected declaration before '}' token
   19 | }
      | ^