Submission #1018173

#TimeUsernameProblemLanguageResultExecution timeMemory
1018173woodRoller Coaster Railroad (IOI16_railroad)C++17
Compilation error
0 ms0 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define eb emplace_back #define fi first #define se second typedef long long ll typedef pair<ll,ll> p32; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { ll res = LLONG_MAX; ll n = (int) s.size(); vector<p32> arr; for(int i = 0; i<n; i++){ arr.eb(s[i],t[i]); } do{ int cost = 0; for(int i = 1; i<n; i++){ cost +=max(0,arr[i-1].se-arr[i].fi); } res = min(res,cost); }while(next_permutation(arr.begin(),arr.end())); return res; }

Compilation message (stderr)

railroad.cpp:8:1: error: expected initializer before 'typedef'
    8 | typedef pair<ll,ll> p32;
      | ^~~~~~~
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:11:2: error: 'll' was not declared in this scope
   11 |  ll res = LLONG_MAX;
      |  ^~
railroad.cpp:12:4: error: expected ';' before 'n'
   12 |  ll n = (int) s.size();
      |    ^~
      |    ;
railroad.cpp:13:9: error: 'p32' was not declared in this scope
   13 |  vector<p32> arr;
      |         ^~~
railroad.cpp:13:12: error: template argument 1 is invalid
   13 |  vector<p32> arr;
      |            ^
railroad.cpp:13:12: error: template argument 2 is invalid
railroad.cpp:14:19: error: 'n' was not declared in this scope
   14 |  for(int i = 0; i<n; i++){
      |                   ^
railroad.cpp:4:12: error: request for member 'emplace_back' in 'arr', which is of non-class type 'int'
    4 | #define eb emplace_back
      |            ^~~~~~~~~~~~
railroad.cpp:15:7: note: in expansion of macro 'eb'
   15 |   arr.eb(s[i],t[i]);
      |       ^~
railroad.cpp:19:20: error: 'n' was not declared in this scope
   19 |   for(int i = 1; i<n; i++){
      |                    ^
railroad.cpp:20:20: error: invalid types 'int[int]' for array subscript
   20 |    cost +=max(0,arr[i-1].se-arr[i].fi);
      |                    ^
railroad.cpp:20:32: error: invalid types 'int[int]' for array subscript
   20 |    cost +=max(0,arr[i-1].se-arr[i].fi);
      |                                ^
railroad.cpp:22:3: error: 'res' was not declared in this scope
   22 |   res = min(res,cost);
      |   ^~~
railroad.cpp:23:30: error: request for member 'begin' in 'arr', which is of non-class type 'int'
   23 |  }while(next_permutation(arr.begin(),arr.end()));
      |                              ^~~~~
railroad.cpp:23:42: error: request for member 'end' in 'arr', which is of non-class type 'int'
   23 |  }while(next_permutation(arr.begin(),arr.end()));
      |                                          ^~~
railroad.cpp:24:9: error: 'res' was not declared in this scope
   24 |  return res;
      |         ^~~