Submission #751524

#TimeUsernameProblemLanguageResultExecution timeMemory
751524somethingnewCyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
double eps = 1e-7; vector<vector<pair<int, double>>> g; vector<int> slv1(vector<int> arr, int n, int k, int h) { priority_queue<pair<double, int>, vector<pair<double, int>>, greater<>> que; for (int i = 0; i < k; ++i) { que.push({0, i}); } vector<double> res(g.size(), 1e18); while (!que.empty()) { auto [prc, v] = que.top(); que.pop(); if (v % n == h) continue; if (1e17 > res[v]) continue; //cout << prc << ' ' << v << '\n'; res[v] = prc; for (auto i : g[v]) que.push({prc + i.second, i.first}); } vector<int> reska; for (int i = 0; i < g.size(); ++i) { if (res[i] < 1e17 and arr[i % n] == 0) reska.push_back(i); } return reska; } double slv2(int n, int k, int h, vector<int> tork) { priority_queue<pair<double, int>, vector<pair<double, int>>, greater<>> que; for (auto i : tork) { que.push({0, i}); } vector<double> res(g.size(), 1e18); while (!que.empty()) { auto [prc, v] = que.top(); que.pop(); if (1e17 > res[v]) continue; //cout << prc << ' ' << v << '\n'; res[v] = prc; for (auto i : g[v]) que.push({prc + i.second, i.first}); } return res[n * k - n + h]; } double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { K = min(K+1, 31); int kn = K * N; //cout << kn << '\n'; g.assign(kn, {}); double dv = 1; for (int j = K - 1; j >= 0; --j) { for (int i = 0; i < M; ++i) { int a = x[i], b = y[i], tm = c[i]; int isa = arr[a]; a += j * N; b += j * N; g[a].push_back({b, tm / dv}); if (isa == 2) { if (j + 1 != K) g[a].push_back({b + N, tm * 2 / dv}); } a = y[i], b = x[i], tm = c[i]; isa = arr[a]; a += j * N; b += j * N; g[a].push_back({b, tm / dv}); if (isa == 2) { if (j + 1 != K) g[a].push_back({b + N, tm * 2 / dv}); } } dv *= 2; } arr[0] = 0; vector<int> tor2 = slv1(arr, N, K, H); double res = slv2(N, K, H, tor2); if (res > 1e17) return -1; return res; }

Compilation message (stderr)

cyberland.cpp:2:1: error: 'vector' does not name a type
    2 | vector<vector<pair<int, double>>> g;
      | ^~~~~~
cyberland.cpp:3:1: error: 'vector' does not name a type
    3 | vector<int> slv1(vector<int> arr, int n, int k, int h) {
      | ^~~~~~
cyberland.cpp:28:34: error: 'vector' has not been declared
   28 | double slv2(int n, int k, int h, vector<int> tork) {
      |                                  ^~~~~~
cyberland.cpp:28:40: error: expected ',' or '...' before '<' token
   28 | double slv2(int n, int k, int h, vector<int> tork) {
      |                                        ^
cyberland.cpp: In function 'double slv2(int, int, int, int)':
cyberland.cpp:29:5: error: 'priority_queue' was not declared in this scope
   29 |     priority_queue<pair<double, int>, vector<pair<double, int>>, greater<>> que;
      |     ^~~~~~~~~~~~~~
cyberland.cpp:29:20: error: 'pair' was not declared in this scope
   29 |     priority_queue<pair<double, int>, vector<pair<double, int>>, greater<>> que;
      |                    ^~~~
cyberland.cpp:29:25: error: expected primary-expression before 'double'
   29 |     priority_queue<pair<double, int>, vector<pair<double, int>>, greater<>> que;
      |                         ^~~~~~
cyberland.cpp:30:19: error: 'tork' was not declared in this scope
   30 |     for (auto i : tork) {
      |                   ^~~~
cyberland.cpp:31:9: error: 'que' was not declared in this scope
   31 |         que.push({0, i});
      |         ^~~
cyberland.cpp:33:5: error: 'vector' was not declared in this scope
   33 |     vector<double> res(g.size(), 1e18);
      |     ^~~~~~
cyberland.cpp:33:12: error: expected primary-expression before 'double'
   33 |     vector<double> res(g.size(), 1e18);
      |            ^~~~~~
cyberland.cpp:34:13: error: 'que' was not declared in this scope
   34 |     while (!que.empty()) {
      |             ^~~
cyberland.cpp:37:20: error: 'res' was not declared in this scope
   37 |         if (1e17 > res[v])
      |                    ^~~
cyberland.cpp:40:9: error: 'res' was not declared in this scope
   40 |         res[v] = prc;
      |         ^~~
cyberland.cpp:41:23: error: 'g' was not declared in this scope
   41 |         for (auto i : g[v])
      |                       ^
cyberland.cpp:44:12: error: 'res' was not declared in this scope
   44 |     return res[n * k - n + h];
      |            ^~~
cyberland.cpp: At global scope:
cyberland.cpp:46:42: error: 'vector' has not been declared
   46 | double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
      |                                          ^~~~~~
cyberland.cpp:46:48: error: expected ',' or '...' before '<' token
   46 | double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
      |                                                ^
cyberland.cpp: In function 'double solve(int, int, int, int, int)':
cyberland.cpp:47:9: error: 'min' was not declared in this scope
   47 |     K = min(K+1, 31);
      |         ^~~
cyberland.cpp:50:5: error: 'g' was not declared in this scope
   50 |     g.assign(kn, {});
      |     ^
cyberland.cpp:54:21: error: 'x' was not declared in this scope
   54 |             int a = x[i], b = y[i], tm = c[i];
      |                     ^
cyberland.cpp:55:23: error: 'arr' was not declared in this scope
   55 |             int isa = arr[a];
      |                       ^~~
cyberland.cpp:57:13: error: 'b' was not declared in this scope
   57 |             b += j * N;
      |             ^
cyberland.cpp:58:32: error: 'tm' was not declared in this scope
   58 |             g[a].push_back({b, tm / dv});
      |                                ^~
cyberland.cpp:63:17: error: 'y' was not declared in this scope
   63 |             a = y[i], b = x[i], tm = c[i];
      |                 ^
cyberland.cpp:63:38: error: 'c' was not declared in this scope
   63 |             a = y[i], b = x[i], tm = c[i];
      |                                      ^
cyberland.cpp:75:5: error: 'arr' was not declared in this scope
   75 |     arr[0] = 0;
      |     ^~~
cyberland.cpp:76:5: error: 'vector' was not declared in this scope
   76 |     vector<int> tor2 = slv1(arr, N, K, H);
      |     ^~~~~~
cyberland.cpp:76:12: error: expected primary-expression before 'int'
   76 |     vector<int> tor2 = slv1(arr, N, K, H);
      |            ^~~
cyberland.cpp:77:32: error: 'tor2' was not declared in this scope
   77 |     double res = slv2(N, K, H, tor2);
      |                                ^~~~