제출 #635352

#제출 시각아이디문제언어결과실행 시간메모리
635352BruteforcemanRoller Coaster Railroad (IOI16_railroad)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> long long sub12(int n, std::vector <int> s, std::vector <int> t) { t.push_back(1); long long dp[1 << 16][17]; for (int mask = 0; mask < (1 << 16); mask++) { for (int i = 0; i < 17; i++) { dp[mask][i] = 1LL << 60; } } for (int i = 0; i < 17; i++) { dp[(1 << n) - 1][i] = 0; } auto f = [&] (auto&& self, int mask, int last) -> long long { if (dp[mask][last] < (1LL << 60)) { return dp[mask][last]; } for (int i = 0; i < n; i++) { if (mask & (1 << i)) { continue; } dp[mask][last] = std::min(dp[mask][last], self(self, mask | (1 << i), i) + std::max(0, t[last] - s[i])); } return dp[mask][last]; }; return f(f, 0, n); } long long plan_roller_coaster(std::vector <int> s, std::vector <int> t) { int n = s.size(); if (n <= 16) { return sub12(n, s, t); } std::vector <int> ep { 0, (int) 1e9 }; for (int i = 0; i < n; i++) { ep.push_back(s[i]); ep.push_back(t[i]); } std::sort(ep.begin(), ep.end()); { std::vector <int> tmp; for (int x : ep) { if (tmp.empty() || x != tmp.back()) { tmp.push_back(x); } } ep = tmp; } std::vector <std::vector <int>> g(ep.size()), h(ep.size()); std::vector <int> din(ep.size(), 0), dou(ep.size(), 0); g[(int) ep.size() - 1].push_back(0); h[0].push_back((int) ep.size() - 1); din[0]++; dou[(int) ep.size() - 1]++; for (int i = 0; i < n; i++) { int u = std::lower_bound(ep.begin(), ep.end(), s[i]) - ep.begin(); int v = std::lower_bound(ep.begin(), ep.end(), t[i]) - ep.begin(); g[u].push_back(v); h[v].push_back(u); din[v]++; dou[u]++; } for (int i = 0; i < (int) ep.size() - 1; i++) { if (din[i] < dou[i]) { return 1; } if (din[i] > dou[i]) { g[i].push_back(i + 1); h[i + 1].push_back(i); din[i + 1] += din[i] - dou[i]; dou[i] += din[i] - dou[i]; } } auto dfs = [&] (auto&& self, int node, const std::vector <std::vector <int>>& gg, std::vector <bool>& vis) -> int { int r = 1; vis[node] = true; for (int x : gg[node]) { if (!vis[x]) { r += self(self, x, gg, vis); } } return r; }; std::vector <bool> vis1(ep.size(), false); std::vector <bool> vis2(ep.size(), false); if (dfs(dfs, 0, g, vis1) < (int) ep.size() || dfs(dfs, 0, h, vis2) < (int) ep.size()) { return 1; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

railroad.cpp: In function 'long long int sub12(int, std::vector<int>, std::vector<int>)':
railroad.cpp:14:20: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
   14 |      auto f = [&] (auto&& self, int mask, int last) -> long long {
      |                    ^~~~
railroad.cpp: In lambda function:
railroad.cpp:22:79: error: expression cannot be used as a function
   22 |        dp[mask][last] = std::min(dp[mask][last], self(self, mask | (1 << i), i) + std::max(0, t[last] - s[i]));
      |                                                                               ^
railroad.cpp: In function 'long long int sub12(int, std::vector<int>, std::vector<int>)':
railroad.cpp:26:22: error: no match for call to '(sub12(int, std::vector<int>, std::vector<int>)::<lambda(int&&, int, int)>) (sub12(int, std::vector<int>, std::vector<int>)::<lambda(int&&, int, int)>&, int, int&)'
   26 |      return f(f, 0, n);
      |                      ^
railroad.cpp:14:15: note: candidate: 'sub12(int, std::vector<int>, std::vector<int>)::<lambda(int&&, int, int)>'
   14 |      auto f = [&] (auto&& self, int mask, int last) -> long long {
      |               ^
railroad.cpp:14:15: note:   no known conversion for argument 1 from 'sub12(int, std::vector<int>, std::vector<int>)::<lambda(int&&, int, int)>' to 'int&&'
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:74:22: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
   74 |      auto dfs = [&] (auto&& self, int node, const std::vector <std::vector <int>>& gg, std::vector <bool>& vis) -> int {
      |                      ^~~~
railroad.cpp: In lambda function:
railroad.cpp:79:35: error: expression cannot be used as a function
   79 |         r += self(self, x, gg, vis);
      |                                   ^
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:86:29: error: no match for call to '(plan_roller_coaster(std::vector<int>, std::vector<int>)::<lambda(int&&, int, const std::vector<std::vector<int> >&, std::vector<bool>&)>) (plan_roller_coaster(std::vector<int>, std::vector<int>)::<lambda(int&&, int, const std::vector<std::vector<int> >&, std::vector<bool>&)>&, int, std::vector<std::vector<int> >&, std::vector<bool>&)'
   86 |      if (dfs(dfs, 0, g, vis1) < (int) ep.size() || dfs(dfs, 0, h, vis2) < (int) ep.size()) {
      |                             ^
railroad.cpp:74:17: note: candidate: 'plan_roller_coaster(std::vector<int>, std::vector<int>)::<lambda(int&&, int, const std::vector<std::vector<int> >&, std::vector<bool>&)>'
   74 |      auto dfs = [&] (auto&& self, int node, const std::vector <std::vector <int>>& gg, std::vector <bool>& vis) -> int {
      |                 ^
railroad.cpp:74:17: note:   no known conversion for argument 1 from 'plan_roller_coaster(std::vector<int>, std::vector<int>)::<lambda(int&&, int, const std::vector<std::vector<int> >&, std::vector<bool>&)>' to 'int&&'
railroad.cpp:86:71: error: no match for call to '(plan_roller_coaster(std::vector<int>, std::vector<int>)::<lambda(int&&, int, const std::vector<std::vector<int> >&, std::vector<bool>&)>) (plan_roller_coaster(std::vector<int>, std::vector<int>)::<lambda(int&&, int, const std::vector<std::vector<int> >&, std::vector<bool>&)>&, int, std::vector<std::vector<int> >&, std::vector<bool>&)'
   86 |      if (dfs(dfs, 0, g, vis1) < (int) ep.size() || dfs(dfs, 0, h, vis2) < (int) ep.size()) {
      |                                                                       ^
railroad.cpp:74:17: note: candidate: 'plan_roller_coaster(std::vector<int>, std::vector<int>)::<lambda(int&&, int, const std::vector<std::vector<int> >&, std::vector<bool>&)>'
   74 |      auto dfs = [&] (auto&& self, int node, const std::vector <std::vector <int>>& gg, std::vector <bool>& vis) -> int {
      |                 ^
railroad.cpp:74:17: note:   no known conversion for argument 1 from 'plan_roller_coaster(std::vector<int>, std::vector<int>)::<lambda(int&&, int, const std::vector<std::vector<int> >&, std::vector<bool>&)>' to 'int&&'