Submission #1029765

#TimeUsernameProblemLanguageResultExecution timeMemory
1029765aufanFountain Parks (IOI21_parks)C++17
Compilation error
0 ms0 KiB
#include "parks.h" #include <bits/stdc++.h> using namespace std; const auto fx[] = {1, 1, -1, -1}; const auto fy[] = {1, -1, 1, -1}; const auto dx[] = {2, 0, -2, 0}; const auto dy[] = {0, 2, 0, -2}; int construct_roads(vector<int> x, vector<int> y) { int n = (int)x.size(); map<pair<int, int>, int> id; set<pair<int, int>> pos; for (int i = 0; i < n; i++) { id[{x[i], y[i]}] = i; for (int k = 0; k < 4; k++) { int nx = x[i] + fx[k]; int ny = y[i] + fy[k]; pos.insert({nx, ny}); } } vector<int> vis(n); function<void(int)> dfs = [&](int z) { vis[z] = 1; for (int k = 0; k < 4; k++) { int nx = x[z] + dx[k]; int ny = y[z] + dy[k]; if (id.count({nx, ny})) { int p = id[{nx, ny}]; if (!vis[p]) { dfs(p); } } } }; dfs(0); if (count(vis.begin(), vis.end(), 1) != n) { return 0; } vector<int> u, v, a, b; for (auto [cx, cy] : pos) { if ((cx + cy) % 4 == 0) { if (id.count({cx - 1, cy - 1}) && id.count({cx - 1, cy + 1})) { u.push_back(id[{cx - 1, cy - 1}]); v.push_back(id[{cx - 1, cy + 1}]); a.push_back(cx); b.push_back(cy); } else if (id.count({cx + 1, cy - 1}) && id.count({cx + 1, cy + 1})) { u.push_back(id[{cx + 1, cy - 1}]); v.push_back(id[{cx + 1, cy + 1}]); a.push_back(cx); b.push_back(cy); } } else if ((cx + cy) % 4 == 2) { if (id.count({cx - 1, cy - 1}) && id.count({cx + 1, cy - 1})) { u.push_back(id[{cx - 1, cy - 1}]); v.push_back(id[{cx + 1, cy - 1}]); a.push_back(cx); b.push_back(cy); } else if (id.count({cx - 1, cy + 1}) && id.count({cx + 1, cy + 1})) { u.push_back(id[{cx - 1, cy + 1}]); v.push_back(id[{cx + 1, cy + 1}]); a.push_back(cx); b.push_back(cy); } } } build(u, v, a, b); return 1; }

Compilation message (stderr)

parks.cpp:6:12: error: 'fx' declared as array of 'const auto'
    6 | const auto fx[] = {1, 1, -1, -1};
      |            ^~
parks.cpp:7:12: error: 'fy' declared as array of 'const auto'
    7 | const auto fy[] = {1, -1, 1, -1};
      |            ^~
parks.cpp:8:12: error: 'dx' declared as array of 'const auto'
    8 | const auto dx[] = {2, 0, -2, 0};
      |            ^~
parks.cpp:9:12: error: 'dy' declared as array of 'const auto'
    9 | const auto dy[] = {0, 2, 0, -2};
      |            ^~
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:19:29: error: 'fx' was not declared in this scope; did you mean 'nx'?
   19 |             int nx = x[i] + fx[k];
      |                             ^~
      |                             nx
parks.cpp:20:29: error: 'fy' was not declared in this scope; did you mean 'ny'?
   20 |             int ny = y[i] + fy[k];
      |                             ^~
      |                             ny
parks.cpp: In lambda function:
parks.cpp:31:29: error: 'dx' was not declared in this scope; did you mean 'x'?
   31 |             int nx = x[z] + dx[k];
      |                             ^~
      |                             x
parks.cpp:32:29: error: 'dy' was not declared in this scope; did you mean 'y'?
   32 |             int ny = y[z] + dy[k];
      |                             ^~
      |                             y