제출 #723117

#제출 시각아이디문제언어결과실행 시간메모리
723117sochu경주 (Race) (IOI11_race)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; set < pii > G[N]; int sz[N]; int a[N * 10]; int K; void getsize(int node , int par) { sz[node] = 1; for(auto to : G[node]) if(to.first != par) { getsize(to.first , node); sz[node] += sz[to.first]; } } int find(int node , int par , int n) { for(auto to : G[node]) if(to.first != par) { if(sz[to.first] > n / 2) return find(to.first , node , n); } return node; } int ans = INT_MAX; void get(int node , int par , int len , int h) { if(len <= K && a[K - len]) ans = min(ans , a[K - len] + h - 1); for(auto to : G[node]) if(to.first != par) get(to.first , node , len + to.second , h + 1); } void add(int node , int par , int len , int h) { if(len <= K) { if(a[len] == 0) a[len] = h - 1; else a[len] = min(a[len] , h - 1); } for(auto to : G[node]) if(to.first != par) add(to.first , node , len + to.second , h + 1); } void solve(int root) { for(int i = 0 ; i <= K ; i++) a[i] = 0; for(auto to : G[root]) { get(to.first , root , to.second , 2); add(to.first , root , to.second , 2); } } void decomp(int root) { getsize(root , 0); int c = find(root , 0 , sz[root]); solve(c); for(auto to : G[c]) { G[to.first].erase({c , to.second}); decomp(to.first); } } int best_path(int n , int k , int H[][2] , int L[]) { K = k; for(int i = 0 ; i < n - 1 ; i++) { int x = H[i][0]; int y = H[i][1]; G[x].insert({y , L[i]}); G[y].insert({x , L[i]}); } decomp(1); if(ans == INT_MAX) ans = -1; return ans; }

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

race.cpp:6:11: error: 'pii' was not declared in this scope
    6 |     set < pii > G[N];
      |           ^~~
race.cpp:6:15: error: template argument 1 is invalid
    6 |     set < pii > G[N];
      |               ^
race.cpp:6:15: error: template argument 2 is invalid
race.cpp:6:15: error: template argument 3 is invalid
race.cpp: In function 'void getsize(int, int)':
race.cpp:16:29: error: 'begin' was not declared in this scope
   16 |         for(auto to : G[node])
      |                             ^
race.cpp:16:29: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
race.cpp:16:29: error: 'end' was not declared in this scope
   16 |         for(auto to : G[node])
      |                             ^
race.cpp:16:29: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
race.cpp: In function 'int find(int, int, int)':
race.cpp:26:29: error: 'begin' was not declared in this scope
   26 |         for(auto to : G[node])
      |                             ^
race.cpp:26:29: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
race.cpp:26:29: error: 'end' was not declared in this scope
   26 |         for(auto to : G[node])
      |                             ^
race.cpp:26:29: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
race.cpp: In function 'void get(int, int, int, int)':
race.cpp:43:29: error: 'begin' was not declared in this scope
   43 |         for(auto to : G[node])
      |                             ^
race.cpp:43:29: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
race.cpp:43:29: error: 'end' was not declared in this scope
   43 |         for(auto to : G[node])
      |                             ^
race.cpp:43:29: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
race.cpp: In function 'void add(int, int, int, int)':
race.cpp:56:29: error: 'begin' was not declared in this scope
   56 |         for(auto to : G[node])
      |                             ^
race.cpp:56:29: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
race.cpp:56:29: error: 'end' was not declared in this scope
   56 |         for(auto to : G[node])
      |                             ^
race.cpp:56:29: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
race.cpp: In function 'void solve(int)':
race.cpp:66:29: error: 'begin' was not declared in this scope
   66 |         for(auto to : G[root])
      |                             ^
race.cpp:66:29: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
race.cpp:66:29: error: 'end' was not declared in this scope
   66 |         for(auto to : G[root])
      |                             ^
race.cpp:66:29: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
race.cpp: In function 'void decomp(int)':
race.cpp:79:26: error: 'begin' was not declared in this scope
   79 |         for(auto to : G[c])
      |                          ^
race.cpp:79:26: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
race.cpp:79:26: error: 'end' was not declared in this scope
   79 |         for(auto to : G[c])
      |                          ^
race.cpp:79:26: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from race.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from race.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:96:18: error: request for member 'insert' in 'G[x]', which is of non-class type 'int'
   96 |             G[x].insert({y , L[i]});
      |                  ^~~~~~
race.cpp:97:18: error: request for member 'insert' in 'G[y]', which is of non-class type 'int'
   97 |             G[y].insert({x , L[i]});
      |                  ^~~~~~