QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#837967#9925. LR Stringza11Compile Error//C++141.5kb2024-12-30 17:19:242024-12-30 17:19:24

Judging History

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

  • [2024-12-30 17:19:24]
  • 评测
  • [2024-12-30 17:19:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;


int index[500003][2];
int main ()
{
    int t;
    cin>>t;
    while(t--) {
        string s;
        cin>>s;
        for(int i = 0;i <s.size()+2;i++)
        {
            index[i][0]=0;
            index[i][1]=0;
        }
        for(int i = s.size()-1;i>=0;i--)
        {
            if(s[i]=='L')
            {
                index[i][0]=0;
                index[i][1]=index[i+1][1]+1;
            }
            else
            {
                index[i][1]=0;
                index[i][0]=index[i+1][0]+1;
            }
        }
        int q;
        cin>>q;
        while(q--)
        {
            string w;
            cin>>w;
            if(w[w.size()-1]=='L'&&s[s.size()-1]!='L')
            {
                cout<<"NO\n";
                continue;
            }
            if(w[0]=='R'&&s[0]!='R')
            {
                cout<<"NO\n";
                continue;
            }
            int j = 0;
            int ans = 0;
            for(int i =0;i < w.size();i++)
            {
                if(w[i]=='L')
                {
                    ans+=index[ans][0]+1;
                }
                else if(w[i]=='R')
                {
                    ans += index[ans][1]+1;
                }
                if(ans > s.size())
                    break;
            }
            if(ans > s.size())
                cout<<"NO\n";
            else
                cout<<"YES\n";
        }
    }
}

Details

answer.code:5:20: error: ‘int index [500003][2]’ redeclared as different kind of entity
    5 | int index[500003][2];
      |                    ^
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/13/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:121,
                 from answer.code:1:
/usr/include/strings.h:61:1: note: previous declaration ‘const char* index(const char*, int)’
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
answer.code: In function ‘int main()’:
answer.code:15:18: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   15 |             index[i][0]=0;
      |                  ^
answer.code:16:18: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   16 |             index[i][1]=0;
      |                  ^
answer.code:22:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   22 |                 index[i][0]=0;
      |                      ^
answer.code:23:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   23 |                 index[i][1]=index[i+1][1]+1;
      |                      ^
answer.code:23:34: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   23 |                 index[i][1]=index[i+1][1]+1;
      |                                  ^
answer.code:27:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   27 |                 index[i][1]=0;
      |                      ^
answer.code:28:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   28 |                 index[i][0]=index[i+1][0]+1;
      |                      ^
answer.code:28:34: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   28 |                 index[i][0]=index[i+1][0]+1;
      |                                  ^
answer.code:53:31: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   53 |                     ans+=index[ans][0]+1;
      |                               ^
answer.code:57:33: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   57 |                     ans += index[ans][1]+1;
      |                                 ^