QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#782354 | #8048. Roman Master | lonwxz | WA | 0ms | 3840kb | C++14 | 878b | 2024-11-25 19:49:46 | 2024-11-25 19:49:59 |
Judging History
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'