제출 #1319940

#제출 시각아이디문제언어결과실행 시간메모리
1319940lknijikaijichiEaster Eggs (info1cup17_eastereggs)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> template <typename T> using vec = vector<T>; #define fi first #define sc second using namespace std; constexpr int maxn = 513; vec<vec<int>> adj(maxn); int timer = 0; vec<int> path(maxn); void dfs(int u, int p) { path[++timer] = u; for (int& v : adj[u]) { if (v != p) dfs(v, u); } } int findEgg (int n, vec<pair<int,int>> edges) { for (auto& edge : edges) { adj[edge.fi].push_back(edge.sc); adj[edge.sc].push_back(edge.fi); } dfs(1, 1); int lo = 1, hi = n; while (lo < hi) { int mid = (lo + hi) >> 1; vec<int> pt; for (int i = 1; i <= mid; ++i) pt.push_back(path[i]); if (query(v)) hi = mid; else lo = mid + 1; } return path[lo]; }

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

eastereggs.cpp:3:13: error: 'vector' does not name a type
    3 | using vec = vector<T>;
      |             ^~~~~~
eastereggs.cpp:10:5: error: 'vec' was not declared in this scope
   10 | vec<vec<int>> adj(maxn);
      |     ^~~
eastereggs.cpp:10:5: error: 'vec' was not declared in this scope
eastereggs.cpp:10:5: error: 'vec' was not declared in this scope
eastereggs.cpp:10:5: error: 'vec' was not declared in this scope
eastereggs.cpp:10:5: error: 'vec' was not declared in this scope
eastereggs.cpp:10:5: error: 'vec' was not declared in this scope
eastereggs.cpp:10:5: error: 'vec' was not declared in this scope
eastereggs.cpp:10:5: error: 'vec' was not declared in this scope
eastereggs.cpp:10:5: error: 'vec' was not declared in this scope
eastereggs.cpp:10:1: error: 'vec' does not name a type
   10 | vec<vec<int>> adj(maxn);
      | ^~~
eastereggs.cpp:12:1: error: 'vec' does not name a type
   12 | vec<int> path(maxn);
      | ^~~
eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:14:9: error: 'path' was not declared in this scope; did you mean 'std::filesystem::__cxx11::path'?
   14 |         path[++timer] = u;
      |         ^~~~
      |         std::filesystem::__cxx11::path
In file included from /usr/include/c++/13/filesystem:49,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:200,
                 from eastereggs.cpp:1:
/usr/include/c++/13/bits/fs_path.h:293:9: note: 'std::filesystem::__cxx11::path' declared here
  293 |   class path
      |         ^~~~
eastereggs.cpp:15:19: error: 'adj' was not declared in this scope
   15 |     for (int& v : adj[u]) {
      |                   ^~~
eastereggs.cpp: At global scope:
eastereggs.cpp:20:21: error: 'vec' has not been declared
   20 | int findEgg (int n, vec<pair<int,int>> edges) {
      |                     ^~~
eastereggs.cpp:20:24: error: expected ',' or '...' before '<' token
   20 | int findEgg (int n, vec<pair<int,int>> edges) {
      |                        ^
eastereggs.cpp: In function 'int findEgg(int, int)':
eastereggs.cpp:21:23: error: 'edges' was not declared in this scope; did you mean 'edge'?
   21 |     for (auto& edge : edges) {
      |                       ^~~~~
      |                       edge
eastereggs.cpp:22:9: error: 'adj' was not declared in this scope
   22 |         adj[edge.fi].push_back(edge.sc);
      |         ^~~
eastereggs.cpp:29:9: error: 'vec' was not declared in this scope
   29 |         vec<int> pt;
      |         ^~~
eastereggs.cpp:29:13: error: expected primary-expression before 'int'
   29 |         vec<int> pt;
      |             ^~~
eastereggs.cpp:31:13: error: 'pt' was not declared in this scope
   31 |             pt.push_back(path[i]);
      |             ^~
eastereggs.cpp:31:26: error: 'path' was not declared in this scope; did you mean 'std::filesystem::__cxx11::path'?
   31 |             pt.push_back(path[i]);
      |                          ^~~~
      |                          std::filesystem::__cxx11::path
/usr/include/c++/13/bits/fs_path.h:293:9: note: 'std::filesystem::__cxx11::path' declared here
  293 |   class path
      |         ^~~~
eastereggs.cpp:32:19: error: 'v' was not declared in this scope
   32 |         if (query(v)) hi = mid;
      |                   ^
eastereggs.cpp:32:13: error: 'query' was not declared in this scope
   32 |         if (query(v)) hi = mid;
      |             ^~~~~
eastereggs.cpp:35:12: error: 'path' was not declared in this scope; did you mean 'std::filesystem::__cxx11::path'?
   35 |     return path[lo];
      |            ^~~~
      |            std::filesystem::__cxx11::path
/usr/include/c++/13/bits/fs_path.h:293:9: note: 'std::filesystem::__cxx11::path' declared here
  293 |   class path
      |         ^~~~