QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#837977#9925. LR Stringza11Compile Error//C++171.5kb2024-12-30 17:24:142024-12-30 17:24:15

Judging History

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

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

answer

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


int index[500009][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";
        }
    }
}

详细

answer.code:5:20: error: ‘int index [500009][2]’ redeclared as different kind of entity
    5 | int index[500009][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:17:18: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   17 |             index[i][0]=0;
      |                  ^
answer.code:18:18: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   18 |             index[i][1]=0;
      |                  ^
answer.code:24:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   24 |                 index[i][0]=0;
      |                      ^
answer.code:25:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   25 |                 index[i][1]=index[i+1][1]+1;
      |                      ^
answer.code:25:34: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   25 |                 index[i][1]=index[i+1][1]+1;
      |                                  ^
answer.code:29:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   29 |                 index[i][1]=0;
      |                      ^
answer.code:30:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   30 |                 index[i][0]=index[i+1][0]+1;
      |                      ^
answer.code:30:34: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   30 |                 index[i][0]=index[i+1][0]+1;
      |                                  ^
answer.code:55:31: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   55 |                     ans+=index[ans][0]+1;
      |                               ^
answer.code:59:33: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   59 |                     ans += index[ans][1]+1;
      |                                 ^