Submission #836242

#TimeUsernameProblemLanguageResultExecution timeMemory
836242unnickCity Mapping (NOI18_citymapping)C++14
Compilation error
0 ms0 KiB
#include "citymapping.h" #include <algorithm> #include <numeric> #include <vector> using namespace std; #define ll long long void find_roads(int N, int Q, int A[], int B[], int W[]) { if (Q <= 12000) { int start; { ll maxd = 0; for (int i = 2; i <= N; i++) { ll d = get_distance(1, i); if (d > maxd) { maxd = d; start = i; } } } // cout << start << "\n"; vector<ll> dists(N); dists[start-1] = 0; vector<int> ids(N); iota(ids.begin(), ids.end(), 0); for (int i = 1; i <= N; i++) { if (i == start) continue; dists[i-1] = get_distance(start,i); } sort(ids.begin(), ids.end(), [&](int a, int b) { return dists[a] < dists[b]; }); for (int i = 0; i < N-1; i++) { A[i] = ids[i]+1; B[i] = ids[i+1]+1; W[i] = dists[ids[i+1]] - dists[ids[i]]; } } else { int k = 0; for (int i = 1; i <= N; i++) { for (j = i+1; j <= N; j++) { if (get_distance(i,j) == 1) { A[k] = i; B[k] = j; W[k++] = 1; } } } } }

Compilation message (stderr)

citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:44:9: error: 'j' was not declared in this scope
   44 |    for (j = i+1; j <= N; j++) {
      |         ^