QOJ.ac

QOJ

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

Judging History

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

  • [2024-12-30 17:17:50]
  • 评测
  • [2024-12-30 17:17:49]
  • 提交

answer

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


int index[1000003][3];
int main ()
{
    int t;
    cin>>t;
    while(t--) {
        string s;
        cin>>s;
        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:21: error: ‘int index [1000003][3]’ redeclared as different kind of entity
    5 | int index[1000003][3];
      |                     ^
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:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   17 |                 index[i][0]=0;
      |                      ^
answer.code:18:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   18 |                 index[i][1]=index[i+1][1]+1;
      |                      ^
answer.code:18:34: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   18 |                 index[i][1]=index[i+1][1]+1;
      |                                  ^
answer.code:22:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   22 |                 index[i][1]=0;
      |                      ^
answer.code:23:22: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   23 |                 index[i][0]=index[i+1][0]+1;
      |                      ^
answer.code:23:34: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   23 |                 index[i][0]=index[i+1][0]+1;
      |                                  ^
answer.code:48:31: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   48 |                     ans+=index[ans][0]+1;
      |                               ^
answer.code:52:33: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
   52 |                     ans += index[ans][1]+1;
      |                                 ^