QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793452#464. 前缀函数 / KMPSin_WattCompile Error//C++14793b2024-11-29 20:04:022024-11-29 20:04:02

Judging History

你现在查看的是最新测评结果

  • [2024-11-29 20:04:02]
  • 评测
  • [2024-11-29 20:04:02]
  • 提交

answer

#include <bits/stdc++.h>

typedef long long lnt;

using namespace std;

const int N = 1e5 + 7;

int n;
int s[N];
int ne[N];

void INIT() { }

void WORK() {
    cin >> (s + 1);
    n = strlen(s + 1);
    for (int i = 2, j = 1; i <= n; ++ i) {
        while (j && s[j + 1] != s[i]) j = ne[j];
        if (s[j + 1] == s[i]) ++ j;
        ne[i] = j;
    }
    for (int i = 1; i <= n; ++ i) {
        cout << ne[i] << '\n';
    }
}

//#define filename ""

int main() {
    #ifdef filename
    freopen(filename ".in", "r", stdin);
    freopen(filename ".out", "w", stdout);
    #endif
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(0);		
    
    int Turn = 1;
    cin >> Turn;
    INIT();
    while (Turn -- ) {
        WORK();
    }
    return;
}

Details

answer.code: In function ‘void WORK()’:
answer.code:16:9: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘int*’)
   16 |     cin >> (s + 1);
      |     ~~~ ^~ ~~~~~~~
      |     |         |
      |     |         int*
      |     std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/13/sstream:40,
                 from /usr/include/c++/13/complex:45,
                 from /usr/include/c++/13/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127,
                 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:16:15: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   16 |     cin >> (s + 1);
      |            ~~~^~~~
/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:16:15: error: invalid conversion from ‘int*’ to ‘long long unsigned int’ [-fpermissive]
   16 |     cin >> (s + 1);
      |            ~~~^~~~
      |               |
      |               int*
answer.code:16:15: error: cannot bind rvalue ‘(long long unsigned int)(((int*)(& s)) + 4)’ 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:16:15: error: invalid conversion from ‘int*’ to ‘long long int’ [-fpermissive]
   16 |     cin >> (s + 1);
      |            ~~~^~~~
      |               |
      |               int*
answer.code:16:15: error: cannot bind rvalue ‘(long long int)(((int*)(& s)) + 4)’ to ‘long long int&’
/usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:192:7: note:   conversion of argument 1 would be ill-formed:
answer.code:16:15: error: invalid conversion from ‘int*’ to ‘long unsigned int’ [-fpermissive]
   16 |     cin >> (s + 1);
      |            ~~~^~~~
      |               |
      |               int*
answer.code:16:15: error: cannot bind rvalue ‘(long unsigned int)(((int*)(& s)) + 4)’ to ‘long unsigned int&’
/usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:188:7: note:   conversion of argument 1 would be ill-formed:
answer.code:16:15: error: invalid conversion from ‘int*’ to ‘long int’ [-fpermissive]
   16 |     cin >> (s + 1);
      |            ~~~^~~~
      |               |
      |               int*
answer.code:16:15: error: cannot bind rvalue ‘(long int)(((int*)(& s)) + 4)’ to ‘long int&’
/usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:184:7: note:   conversion of argument 1 would be ill-formed:
answer.code:16:15: error: invalid conversion from ‘int*’ to ‘unsigned int’ [-fpermissive]
   16 |     cin >> (s + 1);
      |            ~~~^~~~
      |               |
      |               int*
answer.code:16:15: error: cannot bind rvalue ‘(unsigned int)(((int*)(& s)) + 4)’ to ‘unsigned int&’
/usr/include/c++/13/istream:181:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& st...