제출 #1183920

#제출 시각아이디문제언어결과실행 시간메모리
1183920lance0친구 (IOI14_friend)C++20
컴파일 에러
0 ms0 KiB
#include friend.h #include <bits/stdc++.h> int findSample(int n, int confidence[], int host[], int protocol[]) { int dp[n][2] = {}; for (int i = 0; i < n; i++) { dp[i][0] = confidence[i]; } for (int i = n-1; i > 0; i--) { int j = host[i]; if (protocol[i] == 0) { dp[j][0] += dp[i][1]; // dont take invitee dp[j][1] += max(dp[i][0], dp[i][1]); // free to do anything with invitee } else if (protocol[i] == 1) { dp[j][0] += max(dp[i][0], dp[i][1]); // free to do anything with invitee dp[j][0] = max(dp[j][0], dp[j][1] + dp[i][0]); // as well as the case of taking host but not invitee (1 person case) dp[j][1] += dp[i][1]; //dont take either } else { dp[j][0] = max(dp[j][0] + dp[i][1], dp[i][0] + dp[j][1]); // taking one is fine dp[j][1] += dp[i][1]; // and so is taking none } return max(dp[0][0], dp[0][1]) //best is dependent on taking or not person 0, so just look at both. } }

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

friend.cpp:1:10: error: #include expects "FILENAME" or <FILENAME>
    1 | #include friend.h
      |          ^~~~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:13:37: error: 'max' was not declared in this scope
   13 |                         dp[j][1] += max(dp[i][0], dp[i][1]); // free to do anything with invitee
      |                                     ^~~
friend.cpp:13:37: note: suggested alternatives:
In file included from /usr/include/c++/11/string:52,
                 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 friend.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   'std::max'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from friend.cpp:2:
/usr/include/c++/11/bits/ranges_algo.h:3011:29: note:   'std::ranges::max'
 3011 |   inline constexpr __max_fn max{};
      |                             ^~~
friend.cpp:15:37: error: 'max' was not declared in this scope
   15 |                         dp[j][0] += max(dp[i][0], dp[i][1]); // free to do anything with invitee
      |                                     ^~~
friend.cpp:15:37: note: suggested alternatives:
In file included from /usr/include/c++/11/string:52,
                 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 friend.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   'std::max'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from friend.cpp:2:
/usr/include/c++/11/bits/ranges_algo.h:3011:29: note:   'std::ranges::max'
 3011 |   inline constexpr __max_fn max{};
      |                             ^~~
friend.cpp:19:36: error: 'max' was not declared in this scope
   19 |                         dp[j][0] = max(dp[j][0] + dp[i][1], dp[i][0] + dp[j][1]); // taking one is fine
      |                                    ^~~
friend.cpp:19:36: note: suggested alternatives:
In file included from /usr/include/c++/11/string:52,
                 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 friend.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   'std::max'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from friend.cpp:2:
/usr/include/c++/11/bits/ranges_algo.h:3011:29: note:   'std::ranges::max'
 3011 |   inline constexpr __max_fn max{};
      |                             ^~~
friend.cpp:22:24: error: 'max' was not declared in this scope
   22 |                 return max(dp[0][0], dp[0][1]) //best is dependent on taking or not person 0, so just look at both.
      |                        ^~~
friend.cpp:22:24: note: suggested alternatives:
In file included from /usr/include/c++/11/string:52,
                 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 friend.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   'std::max'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from friend.cpp:2:
/usr/include/c++/11/bits/ranges_algo.h:3011:29: note:   'std::ranges::max'
 3011 |   inline constexpr __max_fn max{};
      |                             ^~~
friend.cpp:22:47: error: expected ';' before '}' token
   22 |                 return max(dp[0][0], dp[0][1]) //best is dependent on taking or not person 0, so just look at both.
      |                                               ^
      |                                               ;
   23 |         }
      |         ~