제출 #1257618

#제출 시각아이디문제언어결과실행 시간메모리
1257618makravCity (JOI17_city)C++20
컴파일 에러
0 ms0 KiB
#include "Encoder.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int) (x).size() void Encode(int N, int A[], int B[]) { vector<vector<int>> g(N); for (int i = 0; i < N - 1; i++) { g[A[i]].pb(B[i]); g[B[i]].pb(A[i]); } vector<int> sub(N); vector<vector<int>> g2(N); auto dfs = [&](int v, int p, auto&&self) -> void { sub[v] = 1; for (int u : g[v]) { if (u != p) { g2[v].pb(u); self(u, v, self); sub[v] += sub[u]; } } }; dfs(0, 0, dfs); auto sol = [&](vector<int> roots, int h, ll code, auto&&self) -> void { // ?for (int u : roots) cout << u << ' '; // cout << h << ' ' << code << '\n'; if (roots.empty()) return; vector<int> r2; if (roots.size() == 1) { //cout << "enc " << roots[0] << ' ' << (1ll << h) + code << '\n'; Code(roots[0], (1ll << h) + code); for (int u : g2[roots[0]]) { r2.pb(u); } } else { r2 = roots; } if (r2.empty()) return; sort(all(r2), [&](int x, int y) { return sub[x] > sub[y]; }); if (sub[r2[0]] == 1) { for (int u : r2[0]) { Code(u, (1ll << (h + 1)) + code); } return; } int ts = 0, cts = 0; for (int u : r2) ts += sub[u]; for (int j = 0; j < sz(r2); j++) { cts += sub[r2[j]]; if (cts >= ts / 2) { vector<int> fr, sc; for (int jj = 0; jj <= j; jj++) fr.pb(r2[jj]); for (int jj = j + 1; jj < sz(r2); jj++) sc.pb(r2[jj]); self(fr, h + 1, code, self); self(sc, h + 1, code + (1ll << h), self); break; } } }; sol({0}, 0, 0, sol); }
#include "Device.h" #include <cassert> #include <bits/stdc++.h> using namespace std; using ll = long long; void InitDevice() { } int Answer(long long S, long long T) { if (S == T) return 2; ll H1 = 63 - __builtin_clzll(S), H2 = 63 - __builtin_clzll(T); S -= (1ll << H1); T -= (1ll << H2); //cout << H1 << ' ' << H2 << ' ' << S << ' ' << T << '\n'; if (H1 == H2) return 2; if (H1 < H2) { if ((T % (1ll << H1)) == S) return 1; return 2; } else { if ((S % (1ll << H2)) == T) return 0; return 2; } // if ((S&T) != std::min(S, T)) return 2; // if (H1 < H2) return 1; // return 0; }

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

# 1번째 컴파일 단계

Encoder.cpp: In instantiation of 'Encode(int, int*, int*)::<lambda(std::vector<int>, int, ll, auto:48&&)> [with auto:48 = Encode(int, int*, int*)::<lambda(std::vector<int>, int, ll, auto:48&&)>&; ll = long long int]':
Encoder.cpp:69:5:   required from here
Encoder.cpp:50:25: error: 'begin' was not declared in this scope
   50 |                         for (int u : r2[0]) {
      |                         ^~~
Encoder.cpp:50:25: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from Encoder.cpp:2:
/usr/include/c++/11/valarray:1228:5: note:   'std::begin'
 1228 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Encoder.cpp:2:
/usr/include/c++/11/bits/ranges_base.h:561:44: note:   'std::ranges::__cust::begin'
  561 |     inline constexpr __cust_access::_Begin begin{};
      |                                            ^~~~~
In file included from /usr/include/c++/11/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from Encoder.cpp:2:
/usr/include/c++/11/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
In file included from /usr/include/c++/11/bits/stl_iterator_base_types.h:71,
                 from /usr/include/c++/11/bits/stl_algobase.h:65,
                 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 Encoder.cpp:2:
/usr/include/c++/11/bits/iterator_concepts.h:949:10: note:   'std::ranges::__cust_access::begin'
  949 |     void begin(const auto&) = delete;
      |          ^~~~~
Encoder.cpp:50:25: error: 'end' was not declared in this scope
   50 |                         for (int u : r2[0]) {
      |                         ^~~
Encoder.cpp:50:25: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from Encoder.cpp:2:
/usr/include/c++/11/valarray:1255:5: note:   'std::end'
 1255 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
In file included from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Encoder.cpp:2:
/usr/include/c++/11/bits/ranges_base.h:562:42: note:   'std::ranges::__cust::end'
  562 |     inline constexpr __cust_access::_End end{};
      |                                          ^~~
In file included from /usr/include/c++/11/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from Encoder.cpp:2:
/usr/include/c++/11/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
In file included from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Encoder.cpp:2:
/usr/include/c++/11/bits/ranges_base.h:136:10: note:   'std::ranges::__cust_access::end'
  136 |     void end(const auto&) = delete;
      |          ^~~