Mã chấm Tài khoản Bài tập Ngôn ngữ lập trình Trạng thái Thời gian Bộ nhớ Kích thước Thời gian nộp
269033 Kiều Đức Phúc Chuỗi lớn nhất C/C++ Lỗi biên dịch (CE) 0 MS 0 KB 801 2023-11-18 20:53:56

Lỗi biên dịch:

Main.cc: In function ‘int main()’:
Main.cc:6:5: error: expected initializer before ‘std’
     std::vector aCount(N + 1, 0);
     ^~~
Main.cc:7:10: error: ‘vector’ is not a member of ‘std’
     std::vector bCount(N + 1, 0);
          ^~~~~~
Main.cc:7:17: error: expected primary-expression before ‘int’
     std::vector bCount(N + 1, 0);
                 ^~~
Main.cc:8:10: error: ‘vector’ is not a member of ‘std’
     std::vector count(N + 1, 0);
          ^~~~~~
Main.cc:8:17: error: expected primary-expression before ‘int’
     std::vector count(N + 1, 0);
                 ^~~
Main.cc:10:25: error: ‘N’ was not declared in this scope
     for (int i = 0; i < N; i++) {
                         ^
Main.cc:11:9: error: ‘aCount’ was not declared in this scope
         aCount[i + 1] = aCount[i];
         ^~~~~~
Main.cc:11:9: note: suggested alternative: ‘abort’
         aCount[i + 1] = aCount[i];
         ^~~~~~
         abort
Main.cc:12:9: error: ‘bCount’ was not declared in this scope
         bCount[i + 1] = bCount[i];
         ^~~~~~
Main.cc:12:9: note: suggested alternative: ‘round’
         bCount[i + 1] = bCount[i];
         ^~~~~~
         round
Main.cc:13:9: error: ‘count’ was not declared in this scope
         count[i + 1] = count[i];
         ^~~~~
Main.cc:13:9: note: suggested alternative: ‘round’
         count[i + 1] = count[i];
         ^~~~~
         round
Main.cc:15:13: error: ‘s’ was not declared in this scope
         if (s[i] == 'a') {
             ^
Main.cc:21:13: error: ‘s’ was not declared in this scope
         if (s[i] != '?') {
             ^
Main.cc:28:25: error: ‘N’ was not declared in this scope
     for (int i = 0; i < N; i++) {
                         ^
Main.cc:29:13: error: ‘s’ was not declared in this scope
         if (s[i] == '?') {
             ^
Main.cc:30:33: error: ‘aCount’ was not declared in this scope
             maxSum += std::max({aCount[i], bCount[i], aCount[i] + bCount[i] - count[i] + 1});
                                 ^~~~~~
Main.cc:30:33: note: suggested alternative: ‘abort’
             maxSum += std::max({aCount[i], bCount[i], aCount[i] + bCount[i] - count[i] + 1});
                                 ^~~~~~
                                 abort
Main.cc:30:44: error: ‘bCount’ was not declared in this scope
             maxSum += std::max({aCount[i], bCount[i], aCount[i] + bCount[i] - count[i] + 1});
                                            ^~~~~~
Main.cc:30:44: note: suggested alternative: ‘round’
             maxSum += std::max({aCount[i], bCount[i], aCount[i] + bCount[i] - count[i] + 1});
                                            ^~~~~~
                                            round
Main.cc:30:79: error: ‘count’ was not declared in this scope
             maxSum += std::max({aCount[i], bCount[i], aCount[i] + bCount[i] - count[i] + 1});
                                                                               ^~~~~
Main.cc:30:79: note: suggested alternative: ‘round’
             maxSum += std::max({aCount[i], bCount[i], aCount[i] + bCount[i] - count[i] + 1});
                                                                               ^~~~~
                                                                               round
Main.cc:30:92: error: no matching function for call to ‘max()’
             maxSum += std::max({aCount[i], bCount[i], aCount[i] + bCount[i] - count[i] + 1});
                                                                                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from Main.cc:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
Main.cc:30:92: note:   candidate expects 2 arguments, 1 provided
             maxSum += std::max({aCount[i], bCount[i], aCount[i] + bCount[i] - count[i] + 1});
                                                                                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from Main.cc:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
Main.cc:30:92: note:   candidate expects 3 arguments, 1 provided
             maxSum += std::max({aCount[i], bCount[i], aCount[i] + bCount[i] - count[i] + 1});
                                                                                            ^
Main.cc:34:13: error: expected ‘}’ at end of input
     return 0;
             ^