Submission #1307413

#TimeUsernameProblemLanguageResultExecution timeMemory
1307413robijoyRace (IOI11_race)C++20
Compilation error
0 ms0 KiB
/* * Starting with the name of almighty ALLAH */ // #include <bits/stdc++.h> #include "race.h" using namespace std; #define ll long long const int N = 1e2+3; vector<int> g[N]; ll best_path(int n, int k, int H[][2], int L[]) { n--; for (int i = 0; i < n; ++i) { g[H[i][0]].push_back(H[i][1]); g[H[i][1]].push_back(H[i][0]); } vector<ll> li; li.push_back(0); for (int i = 0; i < n; ++i) li.push_back(L[i]); for (int i = 1; i < n+1; ++i) li[i] += li[i-1]; ll mn = 1e9; for (int i = 0; i < n+1; ++i) { for (int j = i+1; j < n+1; ++j) { ll diff = li[j] - li[i]; if(diff == k) { mn = min((ll)mn, (ll)(j-i)); } } } return mn; } // void solve() { // int n, k; cin>>n>>k; // int H[n-1][2]; // int L[n-1]; // for (int i = 0; i < n-1; ++i) // { // int u,v,w; // cin>>u>>v>>w; // H[i][0] = u; // H[i][1] = v; // L[i] = w; // } // cout<<best_path(n,k,H,L)<<endl; // } // int32_t main() { // ios::sync_with_stdio(false); // cin.tie(0); // int t = 1; // // cin >> t; // while (t--) solve(); // }

Compilation message (stderr)

race.cpp:11:1: error: 'vector' does not name a type
   11 | vector<int> g[N];
      | ^~~~~~
race.cpp:13:4: error: ambiguating new declaration of 'long long int best_path(int, int, int (*)[2], int*)'
   13 | ll best_path(int n, int k, int H[][2], int L[]) {
      |    ^~~~~~~~~
In file included from race.cpp:5:
race.h:1:5: note: old declaration 'int best_path(int, int, int (*)[2], int*)'
    1 | int best_path(int N, int K, int H[][2], int L[]);
      |     ^~~~~~~~~
race.cpp: In function 'long long int best_path(int, int, int (*)[2], int*)':
race.cpp:16:7: error: 'g' was not declared in this scope
   16 |       g[H[i][0]].push_back(H[i][1]);
      |       ^
race.cpp:19:3: error: 'vector' was not declared in this scope
   19 |   vector<ll> li;
      |   ^~~~~~
race.cpp:6:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    5 | #include "race.h"
  +++ |+#include <vector>
    6 | using namespace std;
race.cpp:8:12: error: expected primary-expression before 'long'
    8 | #define ll long long
      |            ^~~~
race.cpp:19:10: note: in expansion of macro 'll'
   19 |   vector<ll> li;
      |          ^~
race.cpp:20:3: error: 'li' was not declared in this scope; did you mean 'll'?
   20 |   li.push_back(0);
      |   ^~
      |   ll
race.cpp:28:14: error: 'min' was not declared in this scope; did you mean 'mn'?
   28 |         mn = min((ll)mn, (ll)(j-i));
      |              ^~~
      |              mn