QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#782354#8048. Roman MasterlonwxzWA 0ms3840kbC++14878b2024-11-25 19:49:462024-11-25 19:49:59

Judging History

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

  • [2024-11-25 19:49:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-11-25 19:49:46]
  • 提交

answer

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3840kb

input:

3
II
IVI
VIIIIIV

output:

2
6
634

result:

wrong answer 2nd lines differ - expected: '16', found: '6'