제출 #797627

#제출 시각아이디문제언어결과실행 시간메모리
797627Joshi503수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; struct ans{ bool ok; vector<int> v; }; struct ans find_journey(int N, int M, vector<int> U, vector<int> V){ if(N == 2){ struct ans; if(M == 1){ ans.ok = 0; return ans; } int ida = -1, regreso = -1; for(int i = 0; i < m; i++){ if(U[i] == 0 && V[i] == 1) ida = i; if(U[i] == 1 && V[i] == 0) regreso = i; } if(ida == -1){ ans.ok = 0; return ans; } vector<int> x; ans.ok = 1; if(regreso != -1){ x.push_back({ida, regreso}); ans.v = x; return ans; } x.push_back({0, 1, 0}); ans.v = x; return ans; } }

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

islands.cpp: In function 'ans find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:15:7: error: expected unqualified-id before '.' token
   15 |    ans.ok = 0;
      |       ^
islands.cpp:16:14: error: expected primary-expression before ';' token
   16 |    return ans;
      |              ^
islands.cpp:19:22: error: 'm' was not declared in this scope
   19 |   for(int i = 0; i < m; i++){
      |                      ^
islands.cpp:24:7: error: expected unqualified-id before '.' token
   24 |    ans.ok = 0;
      |       ^
islands.cpp:25:14: error: expected primary-expression before ';' token
   25 |    return ans;
      |              ^
islands.cpp:28:6: error: expected unqualified-id before '.' token
   28 |   ans.ok = 1;
      |      ^
islands.cpp:30:30: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   30 |    x.push_back({ida, regreso});
      |                              ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from islands.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
islands.cpp:31:7: error: expected unqualified-id before '.' token
   31 |    ans.v = x;
      |       ^
islands.cpp:32:14: error: expected primary-expression before ';' token
   32 |    return ans;
      |              ^
islands.cpp:34:24: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   34 |   x.push_back({0, 1, 0});
      |                        ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from islands.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
islands.cpp:35:6: error: expected unqualified-id before '.' token
   35 |   ans.v = x;
      |      ^
islands.cpp:36:13: error: expected primary-expression before ';' token
   36 |   return ans;
      |             ^