Submission #552727

#TimeUsernameProblemLanguageResultExecution timeMemory
552727iancuTowns (IOI15_towns)C++14
Compilation error
0 ms0 KiB
#include <vector> using namespace std; int hubDistance(int N, int sub) { vector<vector<int>> dist(N, vector<int>(N, -1)); int getDist = [](int a, int b) { if (dist[a][b] == -1) dist[a][b] = dist[b][a] = getDistance(a, b); return dist[a][b]; }; int D1, D2, dist_max = 0; for (int i = 1; i < N; ++i) if (getDist(0, i) > dist_max) { dist_max = getDist(0, i); D1 = i; } dist_max = 0; for (int i = 0; i < N; ++i) if (i != D1 && getDist(D1, i) > dist_max) { dist_max = getDist(D1, i); D2 = i; } int R = getDist(D1, D2); for (int i = 0; i < N; ++i) if (i != D1 && i != D2) { int dist_i = (getDist(D1, i) - getDist(D2, i) + getDist(D1, D2)) / 2; R = min(R, max(dist_i, getDist(D1, D2) - dist_i)); } return R; }

Compilation message (stderr)

towns.cpp: In lambda function:
towns.cpp:8:9: error: 'dist' is not captured
    8 |     if (dist[a][b] == -1)
      |         ^~~~
towns.cpp:7:18: note: the lambda has no capture-default
    7 |   int getDist = [](int a, int b) {
      |                  ^
towns.cpp:6:23: note: 'std::vector<std::vector<int> > dist' declared here
    6 |   vector<vector<int>> dist(N, vector<int>(N, -1));
      |                       ^~~~
towns.cpp:9:7: error: 'dist' is not captured
    9 |       dist[a][b] = dist[b][a] = getDistance(a, b);
      |       ^~~~
towns.cpp:7:18: note: the lambda has no capture-default
    7 |   int getDist = [](int a, int b) {
      |                  ^
towns.cpp:6:23: note: 'std::vector<std::vector<int> > dist' declared here
    6 |   vector<vector<int>> dist(N, vector<int>(N, -1));
      |                       ^~~~
towns.cpp:9:20: error: 'dist' is not captured
    9 |       dist[a][b] = dist[b][a] = getDistance(a, b);
      |                    ^~~~
towns.cpp:7:18: note: the lambda has no capture-default
    7 |   int getDist = [](int a, int b) {
      |                  ^
towns.cpp:6:23: note: 'std::vector<std::vector<int> > dist' declared here
    6 |   vector<vector<int>> dist(N, vector<int>(N, -1));
      |                       ^~~~
towns.cpp:9:33: error: 'getDistance' was not declared in this scope; did you mean 'hubDistance'?
    9 |       dist[a][b] = dist[b][a] = getDistance(a, b);
      |                                 ^~~~~~~~~~~
      |                                 hubDistance
towns.cpp:10:12: error: 'dist' is not captured
   10 |     return dist[a][b];
      |            ^~~~
towns.cpp:7:18: note: the lambda has no capture-default
    7 |   int getDist = [](int a, int b) {
      |                  ^
towns.cpp:6:23: note: 'std::vector<std::vector<int> > dist' declared here
    6 |   vector<vector<int>> dist(N, vector<int>(N, -1));
      |                       ^~~~
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:11:3: error: cannot convert 'hubDistance(int, int)::<lambda(int, int)>' to 'int' in initialization
   11 |   };
      |   ^
towns.cpp:14:21: error: 'getDist' cannot be used as a function
   14 |     if (getDist(0, i) > dist_max) {
      |                     ^
towns.cpp:15:30: error: 'getDist' cannot be used as a function
   15 |       dist_max = getDist(0, i);
      |                              ^
towns.cpp:20:33: error: 'getDist' cannot be used as a function
   20 |     if (i != D1 && getDist(D1, i) > dist_max) {
      |                                 ^
towns.cpp:21:31: error: 'getDist' cannot be used as a function
   21 |       dist_max = getDist(D1, i);
      |                               ^
towns.cpp:24:25: error: 'getDist' cannot be used as a function
   24 |   int R = getDist(D1, D2);
      |                         ^
towns.cpp:27:34: error: 'getDist' cannot be used as a function
   27 |       int dist_i = (getDist(D1, i) - getDist(D2, i) + getDist(D1, D2)) / 2;
      |                                  ^
towns.cpp:27:51: error: 'getDist' cannot be used as a function
   27 |       int dist_i = (getDist(D1, i) - getDist(D2, i) + getDist(D1, D2)) / 2;
      |                                                   ^
towns.cpp:27:69: error: 'getDist' cannot be used as a function
   27 |       int dist_i = (getDist(D1, i) - getDist(D2, i) + getDist(D1, D2)) / 2;
      |                                                                     ^
towns.cpp:28:44: error: 'getDist' cannot be used as a function
   28 |       R = min(R, max(dist_i, getDist(D1, D2) - dist_i));
      |                                            ^
towns.cpp:5:28: warning: unused parameter 'sub' [-Wunused-parameter]
    5 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~