QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#783129#8048. Roman MasterLudovicaCompile Error//C++14803b2024-11-25 23:50:442024-11-25 23:50:44

Judging History

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

  • [2024-11-25 23:50:44]
  • 评测
  • [2024-11-25 23:50:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int T;
int num[9]={0,1,2,3,5,4,6,7,8};
string s1,n[10]={"","I","II","III","V","IV","VI","VII","VIII"};
int a[N];
void solve(){
	int n=s1.size(),tmp=0;
	for(int i=n-1,l=i;i>=0;i=l){
		for(int j=8;j>=1;j--){
			if(i<n[j].size()-1)
				continue;
			bool flag=1;
            for(int k=0;k<n[j].size();k++){
                if(s1[i-k]!=n[j][b[j].size()-1-k]){
                    flag=0;
                    break;
                }
            }
            if(flag){
                a[++tmp]=num[j];
                l=i-n[j].size();
                break;
            }
		}
	}
	for(int i=tmp;i>=1;i--)
		cout<<a[i];
	cout<<"\n"; 
}
int main(){
	cin>>T;
	while(T--){
		cin>>s1;
		solve();
	}
	return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:12:31: error: invalid types ‘int[int]’ for array subscript
   12 |                         if(i<n[j].size()-1)
      |                               ^
answer.code:15:28: error: invalid types ‘int[int]’ for array subscript
   15 |             for(int k=0;k<n[j].size();k++){
      |                            ^
answer.code:16:30: error: invalid types ‘int[int]’ for array subscript
   16 |                 if(s1[i-k]!=n[j][b[j].size()-1-k]){
      |                              ^
answer.code:16:34: error: ‘b’ was not declared in this scope
   16 |                 if(s1[i-k]!=n[j][b[j].size()-1-k]){
      |                                  ^
answer.code:23:22: error: invalid types ‘int[int]’ for array subscript
   23 |                 l=i-n[j].size();
      |                      ^