QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#607061#7814. 消消乐3un_larryfuncCompile Error//C++20400b2024-10-03 13:49:012024-10-03 13:49:02

Details

answer.code: In function ‘int main()’:
answer.code:3:115: error: no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘char*’)
    3 | using namespace std;typedef long long ll;const int N = 2000010;char s[N];int n, g[N];ll f[N];int main() {cin >> n >> (s + 1);ll cnt = 0;for (int i = 1; i <= n; i ++ ) {int j = i - 1;while (s[i] != s[j] && j > 0) j = g[j] - 1;if (j > 0) g[i] = j;}for (int i = 1; i <= n; i ++ ) {if (g[i] > 0) f[i] = f[g[i] - 1] + 1;cnt += f[i];}printf("%lld\n", cnt);return 0;}
      |                                                                                                          ~~~~~~~~ ^~ ~~~~~~~
      |                                                                                                              |          |
      |                                                                                                              |          char*
      |                                                                                                              std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/13/iostream:42,
                 from answer.code:1:
/usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  325 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/13/istream:325:7: note:   conversion of argument 1 would be ill-formed:
answer.code:3:121: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
    3 | using namespace std;typedef long long ll;const int N = 2000010;char s[N];int n, g[N];ll f[N];int main() {cin >> n >> (s + 1);ll cnt = 0;for (int i = 1; i <= n; i ++ ) {int j = i - 1;while (s[i] != s[j] && j > 0) j = g[j] - 1;if (j > 0) g[i] = j;}for (int i = 1; i <= n; i ++ ) {if (g[i] > 0) f[i] = f[g[i] - 1] + 1;cnt += f[i];}printf("%lld\n", cnt);return 0;}
      |                                                                                                                      ~~~^~~~
/usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  201 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:201:7: note:   conversion of argument 1 would be ill-formed:
answer.code:3:121: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
    3 | using namespace std;typedef long long ll;const int N = 2000010;char s[N];int n, g[N];ll f[N];int main() {cin >> n >> (s + 1);ll cnt = 0;for (int i = 1; i <= n; i ++ ) {int j = i - 1;while (s[i] != s[j] && j > 0) j = g[j] - 1;if (j > 0) g[i] = j;}for (int i = 1; i <= n; i ++ ) {if (g[i] > 0) f[i] = f[g[i] - 1] + 1;cnt += f[i];}printf("%lld\n", cnt);return 0;}
      |                                                                                                                      ~~~^~~~
      |                                                                                                                         |
      |                                                                                                                         char*
answer.code:3:121: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& s)) + 1)’ to ‘long long unsigned int&’
/usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  197 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:197:7: note:   conversion of argument 1 would be ill-formed:
answer.code:3:121: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
    3 | using namespace std;typedef long long ll;const int N = 2000010;char s[N];int n, g[N];ll f[N];int main() {cin >> n >> (s + 1);ll cnt = 0;for (int i = 1; i <= n; i ++ ) {int j = i - 1;while (s[i] != s[j] && j > 0) j = g[j] - 1;if (j > 0) g[i] = j;}for (int i = 1; i <= n; i ++ ) {if (g[i] > 0) f[i] = f[g[i] - 1] + 1;cnt += f[i];}printf("%lld\n", cnt);return 0;}
      |                                                                                                                      ~~~^~~~
      |                                                                                                                         |
      |                                                                                                               ...