제출 #1126093

#제출 시각아이디문제언어결과실행 시간메모리
1126093caterpillowMountains (IOI17_mountains)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int n; vector<ll> h; vector<vector<pair<int, int>>> ranges; vector<vector<int>> memo; int dp(int l, int r, int best) { if (r < l || l < 0) return 0; if ((r - l) / 2 < best) return 0; if (memo[l][r] != -1) return memo[l][r]; int res = 1; for (auto [lo, hi] : ranges[r]) { if (hi < l) continue; lo = max(lo, l); res += dp(lo, hi, -1); } return memo[l][r] = max(res, dp(l, r - 1, res)); } int maximum_deevs(vector<int> y) { n = y.size(); h.resize(n); ranges.resize(n); for (int i = 0; i < n; i++) h[i] = y[i]; for (int r = 1; r < n; r++) { int highest = r - 1; for (int i = r - 2; i >= 0; i--) { pair<ll, ll> vec1 = {i - r, h[i] - h[r]}; pair<ll, ll> vec2 = {highest - r, h[highest] - h[r]}; ll x = vec1.first * vec2.second; ll y = vec1.second * vec2.first; if (x - y >= 0) { if (i + 1 <= highest - 1) ranges[r].push_back({i + 1, highest - 1}); highest = i; } } if (highest) ranges[r].push_back({0, highest - 1}); } memo.resize(n, vector<int>(n, -1)); return dp(0, n - 1, -1); } #ifdef LOCAL int main() { int n; assert(1 == scanf("%d", &n)); std::vector<int> y(n); for (int i = 0; i < n; i++) { assert(1 == scanf("%d", &y[i])); } int result = maximum_deevs(y); printf("%d\n", result); return 0; } #endif

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

mountains.cpp: In function 'int dp(int, int, int)':
mountains.cpp:17:26: error: reference to 'ranges' is ambiguous
   17 |     for (auto [lo, hi] : ranges[r]) {
      |                          ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from mountains.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mountains.cpp:8:32: note:                 'std::vector<std::vector<std::pair<int, int> > > ranges'
    8 | vector<vector<pair<int, int>>> ranges;
      |                                ^~~~~~
mountains.cpp: In function 'int maximum_deevs(std::vector<int>)':
mountains.cpp:29:5: error: reference to 'ranges' is ambiguous
   29 |     ranges.resize(n);
      |     ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from mountains.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mountains.cpp:8:32: note:                 'std::vector<std::vector<std::pair<int, int> > > ranges'
    8 | vector<vector<pair<int, int>>> ranges;
      |                                ^~~~~~
mountains.cpp:39:43: error: reference to 'ranges' is ambiguous
   39 |                 if (i + 1 <= highest - 1) ranges[r].push_back({i + 1, highest - 1});
      |                                           ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from mountains.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mountains.cpp:8:32: note:                 'std::vector<std::vector<std::pair<int, int> > > ranges'
    8 | vector<vector<pair<int, int>>> ranges;
      |                                ^~~~~~
mountains.cpp:43:22: error: reference to 'ranges' is ambiguous
   43 |         if (highest) ranges[r].push_back({0, highest - 1});
      |                      ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from mountains.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mountains.cpp:8:32: note:                 'std::vector<std::vector<std::pair<int, int> > > ranges'
    8 | vector<vector<pair<int, int>>> ranges;
      |                                ^~~~~~