제출 #874097

#제출 시각아이디문제언어결과실행 시간메모리
874097itslq친구 (IOI14_friend)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<int> children[1005]; int dp(int w[], int id, bool t) { s = 0; if (t == 0) { for (int c: children[id]) { s += max(dp(w, c, 1), dp(w, c, 0)); } } else { s += w[id]; for (int c: children[id]) { s += dp(w, c, 0); } } return s; } int findSample(int n, int confidence[], int host[], int protocol[]) { if (protocol[1] == 0) { for (int i = 1; i < n; i++) children[host[i]].push_back(i); return max(dp(confidence, 0, 0), dp(confidence, 0, 1)); } else if (protocol[1] == 2) { int m = -1; for (int x: confidence) m = max(m, x); return m; } }

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

friend.cpp: In function 'int dp(int*, int, bool)':
friend.cpp:6:5: error: 's' was not declared in this scope
    6 |     s = 0;
      |     ^
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:26:21: error: 'begin' was not declared in this scope
   26 |         for (int x: confidence) m = max(m, x);
      |                     ^~~~~~~~~~
friend.cpp:26:21: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from friend.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 friend.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
friend.cpp:26:21: error: 'end' was not declared in this scope
   26 |         for (int x: confidence) m = max(m, x);
      |                     ^~~~~~~~~~
friend.cpp:26:21: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from friend.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 friend.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
friend.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^