QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#563659#9288. Roman Palindromeszjy0001AC ✓30ms8444kbC++171.3kb2024-09-14 14:52:132024-09-14 14:52:14

Judging History

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

  • [2024-09-14 14:52:14]
  • 评测
  • 测评结果:AC
  • 用时:30ms
  • 内存:8444kb
  • [2024-09-14 14:52:13]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb long double
#define uLL unsigned long long
using namespace std;
vector<vector<string>>A({
    vector<string>({"","M","MM","MMM"}),
    vector<string>({"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"}),
    vector<string>({"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"}),
    vector<string>({"","I","II","III","IV","V","VI","VII","VIII","IX"})
});
const int N=1e5+5;
int n;
int f[N],pre[N];
string s;
vector<string>B;
inline void write(int x){
    if(x-pre[x])write(x-pre[x]);
    cout<<s.substr(x-pre[x]+1,pre[x])<<'\n';
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    for(auto i:A[0])
        for(auto j:A[1])
            for(auto k:A[2])
                for(auto l:A[3]){
                    auto s=i+j+k+l,t=s;
                    reverse(t.begin(),t.end());
                    if(!s.empty()&&s==t)B.emplace_back(s);
                }
    cin>>n>>s,s=" "+s;
    for(int i=1;i<=n;++i){
        f[i]=n+1;
        for(auto t:B)
            if(i>=t.length()&&s.substr(i-t.length()+1,t.length())==t){
                int w=f[i-t.length()]+1;
                if(w<f[i])f[i]=w,pre[i]=t.length();
            }
    }
    cout<<f[n]<<'\n';
    write(n);
    return 0;
}
/*
*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3604kb

input:

5
MMXXI

output:

3
MM
XX
I

result:

ok OK!

Test #2:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

1
I

output:

1
I

result:

ok OK!

Test #3:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

1
V

output:

1
V

result:

ok OK!

Test #4:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

1
X

output:

1
X

result:

ok OK!

Test #5:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

1
L

output:

1
L

result:

ok OK!

Test #6:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

1
C

output:

1
C

result:

ok OK!

Test #7:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

1
D

output:

1
D

result:

ok OK!

Test #8:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

1
M

output:

1
M

result:

ok OK!

Test #9:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

2
XX

output:

1
XX

result:

ok OK!

Test #10:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

2
LL

output:

2
L
L

result:

ok OK!

Test #11:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

3
XXX

output:

1
XXX

result:

ok OK!

Test #12:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

3
VVV

output:

3
V
V
V

result:

ok OK!

Test #13:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

4
MMMM

output:

2
MMM
M

result:

ok OK!

Test #14:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

4
DDDD

output:

4
D
D
D
D

result:

ok OK!

Test #15:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

5
CCCCC

output:

2
CCC
CC

result:

ok OK!

Test #16:

score: 0
Accepted
time: 1ms
memory: 3860kb

input:

5
DDDDD

output:

5
D
D
D
D
D

result:

ok OK!

Test #17:

score: 0
Accepted
time: 1ms
memory: 3896kb

input:

6
IIIIII

output:

2
III
III

result:

ok OK!

Test #18:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

6
VVVVVV

output:

6
V
V
V
V
V
V

result:

ok OK!

Test #19:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

3
XIX

output:

1
XIX

result:

ok OK!

Test #20:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

5
XIXIX

output:

3
XIX
I
X

result:

ok OK!

Test #21:

score: 0
Accepted
time: 22ms
memory: 6748kb

input:

99999
MCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMC...

output:

49999
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
...

result:

ok OK!

Test #22:

score: 0
Accepted
time: 27ms
memory: 6752kb

input:

100000
LMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMC...

output:

50000
L
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
C
MCM
...

result:

ok OK!

Test #23:

score: 0
Accepted
time: 27ms
memory: 5808kb

input:

100000
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII...

output:

33334
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
III
II...

result:

ok OK!

Test #24:

score: 0
Accepted
time: 22ms
memory: 8444kb

input:

100000
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD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

output:

33333
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CC...

result:

ok OK!

Test #28:

score: 0
Accepted
time: 15ms
memory: 4892kb

input:

58475
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:

19492
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XXX
XX...

result:

ok OK!

Test #29:

score: 0
Accepted
time: 2ms
memory: 4232kb

input:

6696
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD...

output:

6696
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D...

result:

ok OK!

Test #30:

score: 0
Accepted
time: 1ms
memory: 3596kb

input:

15
LLMXILIDXXXIXXD

output:

12
L
L
M
X
I
L
I
D
XX
XIX
X
D

result:

ok OK!

Test #31:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

15
VVIIDILXXIXXXCI

output:

11
V
V
II
D
I
L
X
XIX
XX
C
I

result:

ok OK!

Test #32:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

15
LMMCMMMMXLCLCCC

output:

9
L
M
MCM
MMM
X
L
C
L
CCC

result:

ok OK!

Test #33:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

15
CCCXCCDLDDMVCXI

output:

12
CC
CXC
C
D
L
D
D
M
V
C
X
I

result:

ok OK!

Test #34:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

15
XXXIXXXVVLDXLXL

output:

11
XX
XIX
XX
V
V
L
D
X
L
X
L

result:

ok OK!

Test #35:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

15
IMICVDCXXXIXXXX

output:

10
I
M
I
C
V
D
C
XX
XIX
XXX

result:

ok OK!

Test #36:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

15
CIMMXMCVMMMMCMM

output:

10
C
I
MM
X
M
C
V
MMM
MCM
M

result:

ok OK!

Test #37:

score: 0
Accepted
time: 1ms
memory: 3828kb

input:

15
VDCCCCXCCCCLDVM

output:

9
V
D
CCC
CXC
CCC
L
D
V
M

result:

ok OK!

Test #38:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

15
CCCCXCCCCIDCDVX

output:

9
CCC
CXC
CCC
I
D
C
D
V
X

result:

ok OK!

Test #39:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

15
DXVCCCXCXCCLDDX

output:

11
D
X
V
CCC
X
CXC
C
L
D
D
X

result:

ok OK!

Test #40:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

15
LIIMXXIXIXXXCLX

output:

10
L
II
M
XX
I
XIX
XX
C
L
X

result:

ok OK!

Test #41:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

15
CDLXVMMCMCMMMMD

output:

10
C
D
L
X
V
MM
C
MCM
MMM
D

result:

ok OK!

Test #42:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

15
XXXIXIXXVMLDVMX

output:

11
XXX
I
XIX
X
V
M
L
D
V
M
X

result:

ok OK!

Test #43:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

15
MVDIXIMMMCMCMMM

output:

10
M
V
D
I
X
I
MMM
C
MCM
MM

result:

ok OK!

Test #44:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

15
CCCXCXCCCCMCDCC

output:

8
CCC
X
CXC
CCC
M
C
D
CC

result:

ok OK!

Test #45:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

15
VLVDDMCCCCXCXCC

output:

10
V
L
V
D
D
M
CCC
CXC
X
CC

result:

ok OK!

Test #46:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

15
VDXXVXXXXIXIXXX

output:

8
V
D
XX
V
XXX
XIX
I
XXX

result:

ok OK!

Test #47:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

15
DXMCCCCXCXCCCCM

output:

9
D
X
M
CCC
CXC
X
CCC
C
M

result:

ok OK!

Test #48:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

15
XMIDMLMMCMCMCMM

output:

11
X
M
I
D
M
L
M
MCM
C
MCM
M

result:

ok OK!

Test #49:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

15
XVLVMMCMCMCMMML

output:

10
X
V
L
V
M
MCM
C
MCM
MM
L

result:

ok OK!

Test #50:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

15
DMDDMMCMCMCMMMM

output:

9
D
M
D
D
M
MCM
C
MCM
MMM

result:

ok OK!

Test #51:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

15
VDCCCXCXCXCCIVC

output:

10
V
D
CC
CXC
X
CXC
C
I
V
C

result:

ok OK!

Test #52:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

15
MMMCMCMCMMMDVVM

output:

9
MM
MCM
C
MCM
MM
D
V
V
M

result:

ok OK!

Test #53:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

15
CXXXIXIXIXXXXMV

output:

8
C
XX
XIX
I
XIX
XXX
M
V

result:

ok OK!

Test #54:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

15
DVCCCCXCXCXCCID

output:

9
D
V
CCC
CXC
X
CXC
C
I
D

result:

ok OK!

Test #55:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

15
DMMMMCMCMCMMMIC

output:

8
D
MMM
MCM
C
MCM
MM
I
C

result:

ok OK!

Test #56:

score: 0
Accepted
time: 1ms
memory: 3828kb

input:

15
LMMMMCMCMCMMMML

output:

7
L
MMM
MCM
C
MCM
MMM
L

result:

ok OK!

Test #57:

score: 0
Accepted
time: 20ms
memory: 6760kb

input:

71523
IDVVXCMXMDILVDXDVIDLVXMIICDCIDIDIMVLVVCXDLMICDIXLLVDXCIDDCLMVMLIIMXIMCCXIIMCXVMIMLXDIIXILMDVDIDIXCXMIDXXIIDMVVIIVICIVCIVIMMMDMCDMLCMXVCLXLVDMXDMMVXLDXIDLIDXDXDVXVDIDILXVVIXDMXVVMDICCVCIMVLMXCXMXCXCMCVIDDDIDXCCLCXCIDCIVVIICIXCIXVIVIICIIVILVVMLCCXMMXCDXDXMCIVDMXMMLXXIVVVILXMLIXDILXMCLCLICLDXDMCM...

output:

64586
I
D
V
V
X
C
M
X
M
D
I
L
V
D
X
D
V
I
D
L
V
X
M
II
C
D
C
I
D
I
D
I
M
V
L
V
V
C
X
D
L
M
I
C
D
I
X
L
L
V
D
X
C
I
D
D
C
L
M
V
M
L
II
M
X
I
M
CC
X
II
M
C
X
V
M
I
M
L
X
D
II
X
I
L
M
D
V
D
I
D
I
X
C
X
M
I
D
XX
II
D
M
V
V
II
V
I
C
I
V
C
I
V
I
MMM
D
M
C
D
M
L
C
M
X
V
C
L
X
L
V
D
M
X
D
MM
V
X
L
D
X
I
D
L...

result:

ok OK!

Test #58:

score: 0
Accepted
time: 26ms
memory: 7616kb

input:

90056
XXICXIDMVVIVVICXCDXMMCVXCDCICVMXCVLCCCLVDXCXMXMCXCIDXDCDVXLLDXILXCXXLIDDMLIIMXXIXXCLCDXDVDMLDXLMMXVXLILCLLCVMMDVVCLLDLXIMLICDDDCXMLXVDIMMLIVDXVXIVCXLXLDVVVLMMMLMMXMXVIILCLDDIIMCXMCIILLLMVLMLMXCVIXDIXDDIVDIICXCXVCIILDLMCCCCLCMXDLLCVLCICDMLLXLCDIDVLDVIDXDDLXVCIMVIVDDDCMXMLDXXILVMCMXLDLLCDXMVLMLV...

output:

81443
XX
I
C
X
I
D
M
V
V
I
V
V
I
CXC
D
X
MM
C
V
X
C
D
C
I
C
V
M
X
C
V
L
CCC
L
V
D
X
C
X
M
X
M
CXC
I
D
X
D
C
D
V
X
L
L
D
X
I
L
X
C
XX
L
I
D
D
M
L
II
M
X
XIX
X
C
L
C
D
X
D
V
D
M
L
D
X
L
MM
X
V
X
L
I
L
C
L
L
C
V
MM
D
V
V
C
L
L
D
L
X
I
M
L
I
C
D
D
D
C
X
M
L
X
V
D
I
MM
L
I
V
D
X
V
X
I
V
C
X
L
X
L
D
V
V
V...

result:

ok OK!

Test #59:

score: 0
Accepted
time: 17ms
memory: 6572kb

input:

59078
DVMIVMICDXVDLLDVMIIVCICMXXVMDVDLMMCDIXLMMIXILIXIMVCCDMXLCLVVCXDIIVDVXIMXMCVCCIXCXCDLLVCMLIXXLMIDLMCVXMVDDVMLMDDMDVDXVXVCMVVCDVDVILDMCIVLXCDDXMICCMXVCCLIMVVILXLDMLXVLLMVCDIIXCCIVDIDIMIXICXIXIIXVCMXVMMDLLMXCCMMLCVLLVCCXLCVIXVICMMCCDLXXLCCMXDCVCMDCXMDVLCCIVVIILIDCLDLDXVVICCCIIDMVXCLLDLVXDMXVVDVML...

output:

53523
D
V
M
I
V
M
I
C
D
X
V
D
L
L
D
V
M
II
V
C
I
C
M
XX
V
M
D
V
D
L
MM
C
D
I
X
L
MM
I
X
I
L
I
X
I
M
V
CC
D
M
X
L
C
L
V
V
C
X
D
II
V
D
V
X
I
M
X
M
C
V
CC
I
X
CXC
D
L
L
V
C
M
L
I
XX
L
M
I
D
L
M
C
V
X
M
V
D
D
V
M
L
M
D
D
M
D
V
D
X
V
X
V
C
M
V
V
C
D
V
D
V
I
L
D
M
C
I
V
L
X
C
D
D
X
M
I
CC
M
X
V
CC
L
I
M
...

result:

ok OK!

Test #60:

score: 0
Accepted
time: 13ms
memory: 6336kb

input:

57771
MXXMVIVXLCDMILMVVMDCIDVDLXXMXCVMLDLCXIVLVCCIMXVVMXCMMCCMXIMMVVDXVIMIIIMXVIDVLCXXIVVVXXIIXDCIVICLLLCXLILXMICIVXVMVDXLDLLXILDCLXXIMVIDLCMVLIMVCLDMIMIVCL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V
D
V
V
C
XX
I
C
D
D
D
M
L
D
M
X
D
L
M
C
D
X
...

result:

ok OK!

Test #62:

score: 0
Accepted
time: 15ms
memory: 5876kb

input:

50214
DMIDVCDXMVDICMLLLCLVLXDVLVVCDDXLCMCXLVCCDCCIDVLMVIVXXVCDDMLDVCIVLDICXXXCCLXVIDLDCMLVLILDVXXVVCCCIMMLDLLVXVCDXLMCCIMDDMVDVDLCMMVXMCLLCCIXXXDVDDXIMCDCIXMXVICICXMCVXVCCXMICDXCVMVCXMIDMXDCXDLILDDMCIDIXVILICCDLDDIMVLDICCCDXDLVCDLDVVVLCMCDLCCMIIXXVDMMXDXLLCVDVXILIIVCCCLXDLDCIMVIXVLMMDXILXMMMLXCDVXCI...

output:

45281
D
M
I
D
V
C
D
X
M
V
D
I
C
M
L
L
L
C
L
V
L
X
D
V
L
V
V
C
D
D
X
L
C
M
C
X
L
V
CC
D
CC
I
D
V
L
M
V
I
V
XX
V
C
D
D
M
L
D
V
C
I
V
L
D
I
C
XXX
CC
L
X
V
I
D
L
D
C
M
L
V
L
I
L
D
V
XX
V
V
CCC
I
MM
L
D
L
L
V
X
V
C
D
X
L
M
CC
I
M
D
D
M
V
D
V
D
L
C
MM
V
X
M
C
L
L
CC
I
XXX
D
V
D
D
X
I
M
C
D
C
I
X
M
X
V
I
C...

result:

ok OK!

Test #63:

score: 0
Accepted
time: 28ms
memory: 8172kb

input:

96571
CICMCXCCCXDDCDDIDDCMMDIXVCCXCLMLILXMMLLDXDDIMIIDXXLIVXMLLXLVLMDLCLXLXLCVMLCDDLLMXDICCVIVCLCLXVLVXXIDIMMXCLMXIDIVXCIMXCIXCCIMCCXVIVMCLLMMIIDIIVVDCLIDLVVIIDIMDDXILVMXXXIVLICCCXVCCMCCCLCDVVIDIXIICLMMDIIMLMLCXXVDDMLMIMVIMXLXIVXVCVXMVCICLMXVLCLCLILVIXDMVCILIXIVMLLIMIVLDVIXLCVCLMIDDXVLCDVXCLIVLXDDLI...

output:

87442
C
I
C
M
CXC
CC
X
D
D
C
D
D
I
D
D
C
MM
D
I
X
V
C
CXC
L
M
L
I
L
X
MM
L
L
D
X
D
D
I
M
II
D
XX
L
I
V
X
M
L
L
X
L
V
L
M
D
L
C
L
X
L
X
L
C
V
M
L
C
D
D
L
L
M
X
D
I
CC
V
I
V
C
L
C
L
X
V
L
V
XX
I
D
I
MM
X
C
L
M
X
I
D
I
V
X
C
I
M
X
C
I
X
CC
I
M
CC
X
V
I
V
M
C
L
L
MM
II
D
II
V
V
D
C
L
I
D
L
V
V
II
D
I
M
...

result:

ok OK!

Test #64:

score: 0
Accepted
time: 22ms
memory: 6956kb

input:

73474
ICMILXDIIVVLCLDCLXDDXVIXMXXLLMXCDCMDCVCCDDVMIIMXLLVCCLDIMLXVCVLLXVIMMLMLVMXCIVCLDDMVMDVMXDCIXDIMMVDMIVCIMCDDDXMIDXMVVCXMXMMXVLIDIIXIMVMDVILCXXDXXLMIILXLLILMDCDMMDLDCDIMXDLXIDXXLMXIIMDVIXMVIMMXXDLMCVMMIIDLDIXLMMCLVCCLMLXVVCMMDDCLDXCDVXLCMDLLDDMXMIDVMMCIVIXIXIVXIVDXMLIVCIMILDIIIMVXXXIIXDMVLMXIDC...

output:

66397
I
C
M
I
L
X
D
II
V
V
L
C
L
D
C
L
X
D
D
X
V
I
X
M
XX
L
L
M
X
C
D
C
M
D
C
V
CC
D
D
V
M
II
M
X
L
L
V
CC
L
D
I
M
L
X
V
C
V
L
L
X
V
I
MM
L
M
L
V
M
X
C
I
V
C
L
D
D
M
V
M
D
V
M
X
D
C
I
X
D
I
MM
V
D
M
I
V
C
I
M
C
D
D
D
X
M
I
D
X
M
V
V
C
X
M
X
MM
X
V
L
I
D
II
X
I
M
V
M
D
V
I
L
C
XX
D
XX
L
M
II
L
X
L
L
...

result:

ok OK!

Test #65:

score: 0
Accepted
time: 25ms
memory: 7460kb

input:

87700
LDIIXXMLXLMMLCXCDMMLCCLCVXDIVVXDVVXVDMCCVDLLXDLCXLLMC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
V
M
II
C
I
C
L
V
V
L
L
L
V
C
V
X
D
MMM
MM
X
D
L
C
M
D
I
M
C
D
C
D
M
D
C
M
L
I
X
V
M
D
V
C
V
M
C
L
CC
D
I
V
C
XX
I
M
C
L
X
V
MM
I
D
M
XX
C
I
D
L
...

result:

ok OK!

Test #67:

score: 0
Accepted
time: 16ms
memory: 6128kb

input:

54420
MIXLMCCVDDLIXIVXXVXDMIMLDCDIXVCILVVIILLCXMILXVDILVVMIIMCILMIDMLDILVVMDCDVIDLLLCCMMVCIMLIXXLVVIVDIXXICVXXCIXCDXMLLMIXLXLIDVDMMDVXLXVVVMVXIDVVDXDXXLILLDVCCCLDVCXDDDLMDDIIDCVLIVDXXDVIIMLVVCDLILIMLVXVCDMVIDDCLDDILMMXMIXMDMXXMLXMIMLXMDMIDXVLXLMVVXCVXIXDCLDCLMVLDCLVXICCMIMCICXIMLVLMCDLVXMCDDMVDIVILX...

output:

49254
M
I
X
L
M
CC
V
D
D
L
I
X
I
V
XX
V
X
D
M
I
M
L
D
C
D
I
X
V
C
I
L
V
V
II
L
L
C
X
M
I
L
X
V
D
I
L
V
V
M
II
M
C
I
L
M
I
D
M
L
D
I
L
V
V
M
D
C
D
V
I
D
L
L
L
CC
MM
V
C
I
M
L
I
XX
L
V
V
I
V
D
I
XX
I
C
V
XX
C
I
X
C
D
X
M
L
L
M
I
X
L
X
L
I
D
V
D
MM
D
V
X
L
X
V
V
V
M
V
X
I
D
V
V
D
X
D
XX
L
I
L
L
D
V
CCC...

result:

ok OK!

Test #68:

score: 0
Accepted
time: 24ms
memory: 7880kb

input:

97374
IDXCMDCVILVXXXVIDXDXVXCDVILMXCXXMDDLDCMDLMLIVILVDDCDCCDLXMCVLVXMMDIDVXXMDVCICICDDCXLMCLMCXMMDDVCDVVXLXDXVDIDXIDXXVCDLDXDDMVXIILVDIVLVCVLXXVIDCVCVIVLMCMMXXVXXVMDIDDICVIVLMVICVIVDDLICLCXIXXMCMDIDDVLIXLDICVMDLDMVDMIVMVDLCMICMVMXCXLIICDCLLCVCDICCLXIVILXXLXCLLXMCDMXCMICLLVIMDVDVXVXCCIXXDVXVDDXXLVMM...

output:

88063
I
D
X
C
M
D
C
V
I
L
V
XXX
V
I
D
X
D
X
V
X
C
D
V
I
L
M
X
C
XX
M
D
D
L
D
C
M
D
L
M
L
I
V
I
L
V
D
D
C
D
CC
D
L
X
M
C
V
L
V
X
MM
D
I
D
V
XX
M
D
V
C
I
C
I
C
D
D
C
X
L
M
C
L
M
C
X
MM
D
D
V
C
D
V
V
X
L
X
D
X
V
D
I
D
X
I
D
XX
V
C
D
L
D
X
D
D
M
V
X
II
L
V
D
I
V
L
V
C
V
L
XX
V
I
D
C
V
C
V
I
V
L
MCM
M
XX...

result:

ok OK!

Test #69:

score: 0
Accepted
time: 16ms
memory: 6048kb

input:

54017
DDLCMICXCXVVLVVILCVVIXCVDMLDDXIMMXVIXILILMLIXIVMLDVVXDICCVMLDIXCLMVCDIVMIMILCLMXLDXIMVMDXLXDCMVIVXXICVVMMIIXXICXVCIXVMXLILMILLLMLXCMVLDDMVVICMIXDLCCICDVMDLDIIVICLXICMLCMMVCXIDDVXCMDXCDLIDIDIXMVXVDLICCIDVMVCIMCDVCCDCVDVIXXCLILXLILILMIVXDLLXXLLCMVVDXDDXCXICLVMDICIXDLCMICVDXDLVLCMVXCIMIVVMLVCCLLI...

output:

48823
D
D
L
C
M
I
CXC
X
V
V
L
V
V
I
L
C
V
V
I
X
C
V
D
M
L
D
D
X
I
MM
X
V
I
X
I
L
I
L
M
L
I
X
I
V
M
L
D
V
V
X
D
I
CC
V
M
L
D
I
X
C
L
M
V
C
D
I
V
M
I
M
I
L
C
L
M
X
L
D
X
I
M
V
M
D
X
L
X
D
C
M
V
I
V
XX
I
C
V
V
MM
II
XX
I
C
X
V
C
I
X
V
M
X
L
I
L
M
I
L
L
L
M
L
X
C
M
V
L
D
D
M
V
V
I
C
M
I
X
D
L
CC
I
C
D
V...

result:

ok OK!

Test #70:

score: 0
Accepted
time: 17ms
memory: 7012kb

input:

74705
DMVICLMXIDCIVICLCLXILIIDDDIXCXCVIMMLDIVVXVVCDXXVLVMDXDVXVCLCXCVXDIVDLVDVXDLXLDILXMXIVDXVXMMMMDMLCLMXDLLLLDXVCDIDCDXXXCLXDVVVDLLXVILVMXVCLXLDLXCDMIICLXVCCICCDVDVMMMIIXLMCLXXMCLVCXVMDMDMVDCLDVDDCXIDIILIDDLIDVILMXMVCVILCMMIVMCXDXCMIDMVCVLILDMDDLDICMICCXCXIVDVMVXIILLDCMDVMLLIDCVLCVVVCVVCCXXXDLDDMD...

output:

67511
D
M
V
I
C
L
M
X
I
D
C
I
V
I
C
L
C
L
X
I
L
II
D
D
D
I
X
CXC
V
I
MM
L
D
I
V
V
X
V
V
C
D
XX
V
L
V
M
D
X
D
V
X
V
C
L
CXC
V
X
D
I
V
D
L
V
D
V
X
D
L
X
L
D
I
L
X
M
X
I
V
D
X
V
X
MMM
M
D
M
L
C
L
M
X
D
L
L
L
L
D
X
V
C
D
I
D
C
D
XXX
C
L
X
D
V
V
V
D
L
L
X
V
I
L
V
M
X
V
C
L
X
L
D
L
X
C
D
M
II
C
L
X
V
CC
I...

result:

ok OK!

Test #71:

score: 0
Accepted
time: 30ms
memory: 8092kb

input:

99127
XXXIXVLILLVDVMLCMICMVLIXCMLMMMMIDDICDLICXLDCLDVDCIVDICDMVXCLXCVLLDVDMCVIMVIXDLLCLDCIDLXDDXVCVLLCVIXVDIXDMXXLIVCIILLLILMVXCLDVVMIIDIDICDICXVXCVLICVCLMLDLILXDDMCVVCMCLLVDCDMIXIIMXIMDCMXXCVCMDMMCDCXLVXVLXXMXVMLVXXMXCCILDICCMLDLLDVIXIIVXLLLIMMMCXDLXMCCCMXVDLCDDLIDMCDCMIXLCIVDCMMIMXIIMICXCLMIDVCCCM...

output:

89463
XX
XIX
V
L
I
L
L
V
D
V
M
L
C
M
I
C
M
V
L
I
X
C
M
L
MMM
M
I
D
D
I
C
D
L
I
C
X
L
D
C
L
D
V
D
C
I
V
D
I
C
D
M
V
X
C
L
X
C
V
L
L
D
V
D
M
C
V
I
M
V
I
X
D
L
L
C
L
D
C
I
D
L
X
D
D
X
V
C
V
L
L
C
V
I
X
V
D
I
X
D
M
XX
L
I
V
C
II
L
L
L
I
L
M
V
X
C
L
D
V
V
M
II
D
I
D
I
C
D
I
C
X
V
X
C
V
L
I
C
V
C
L
M
L
D
...

result:

ok OK!

Test #72:

score: 0
Accepted
time: 24ms
memory: 7836kb

input:

94936
LCDVXVIXICCXXILMLMXMLVDIXCMILVVIMLLLLILIVXMILXMVVILCCIVIMXIXMIDCVCVCMMXCMDXLMCVIDMVXXIXIXLCXDCCXVMDCVVLLMIIXCMVMLMLCVCMVLDCMDDLDXIIXMDMICCVICLIXVILXLVLIVVCXDMLXLCLIVXICICVXLCLIXMCDCIDVMMIILCICVXXCMXIDDMMIXMIMVMLIIMLXCMVDLDCVLXCDIVLIIMVMCIXLMXXCVVCMIDLVIXDDVDIDMCLICDDMVVIIMVCXMMLICXXIIMDIDCMXMM...

output:

85968
L
C
D
V
X
V
I
X
I
CC
XX
I
L
M
L
M
X
M
L
V
D
I
X
C
M
I
L
V
V
I
M
L
L
L
L
I
L
I
V
X
M
I
L
X
M
V
V
I
L
CC
I
V
I
M
XIX
M
I
D
C
V
C
V
C
MM
X
C
M
D
X
L
M
C
V
I
D
M
V
XX
I
XIX
L
C
X
D
CC
X
V
M
D
C
V
V
L
L
M
II
X
C
M
V
M
L
M
L
C
V
C
M
V
L
D
C
M
D
D
L
D
X
II
X
M
D
M
I
CC
V
I
C
L
I
X
V
I
L
X
L
V
L
I
V
V...

result:

ok OK!

Test #73:

score: 0
Accepted
time: 17ms
memory: 6428kb

input:

57440
CLDCCICDILDDLLIVXLIDMVDCXDIMICMDIMMICVCVVXIMCIMIDCVIVCIMLCMLLVDVDVXMLDXCLIDMXMLCVXCDVLVLIVIIDDVLLXXICXVLVCLXIXDLDLDCDMCVXILXMLCCCMLLMIDVCLLLV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XIXCXIXIXMXIXIX...

output:

61569
V
XIX
I
X
C
XIX
I
X
M
XIX
I
X
C
XIX
I
X
D
XIX
I
XXX
I
XIX
XX
I
XIX
XX
I
XIX
XX
I
XIX
V
XIX
I
X
M
XIX
I
X
L
XIX
I
X
L
XIX
I
XXX
I
XIX
M
XIX
I
X
M
XIX
I
X
C
XIX
I
X
C
XIX
I
X
M
XIX
I
X
V
XIX
I
XXX
I
XIX
L
XIX
I
X
M
XIX
I
X
M
XIX
I
X
D
XIX
I
X
L
XIX
I
X
M
XIX
I
X
D
XIX
I
X
D
XIX
I
X
M
XIX
I
X
M
X...

result:

ok OK!

Test #77:

score: 0
Accepted
time: 27ms
memory: 7196kb

input:

99816
DMCMCMLMCMCMXMCMCMVMCMCMMMCMCMXMCMCMXMCMCMVMCMCMLMCMCMLMCMCMLMCMCMMMCMCMIMCMCMMMCMCMLMCMCMDMCMCMIMCMCMDMCMCMXMCMCMIMCMCMIMCMCMXMCMCMXMCMCMLMCMCMVMCMCMIMCMCMXMCMCMXMCMCMDMCMCMXMCMCMXMCMCMXMCMCMXMCMCMXMCMCMVMCMCMXMCMCMVMCMCMIMCMCMMMCMCMVMCMCMXMCMCMLMCMCMXMCMCMIMCMCMLMCMCMIMCMCMIMCMCMVMCMCMIMCMCM...

output:

61551
D
MCM
C
M
L
MCM
C
M
X
MCM
C
M
V
MCM
C
MMM
C
MCM
X
MCM
C
M
X
MCM
C
M
V
MCM
C
M
L
MCM
C
M
L
MCM
C
M
L
MCM
C
MMM
C
MCM
I
MCM
C
MMM
C
MCM
L
MCM
C
M
D
MCM
C
M
I
MCM
C
M
D
MCM
C
M
X
MCM
C
M
I
MCM
C
M
I
MCM
C
M
X
MCM
C
M
X
MCM
C
M
L
MCM
C
M
V
MCM
C
M
I
MCM
C
M
X
MCM
C
M
X
MCM
C
M
D
MCM
C
M
X
MCM
C
M
...

result:

ok OK!

Test #78:

score: 0
Accepted
time: 20ms
memory: 7568kb

input:

82203
MVCMCDMIIMMXC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
C
V
L
I
D
C
I
M
CCC
V
V
C
XX
C
X
L
L
L
L
L
L
I
V
I
C
D
I
V
XX
CC
D
M
CC
M
L
M
L
M
X
D
I
V
L
M
X
V
I
D
D
I
M
D
L
I
X
D
M
C
V
C
V
C
L
M
C
X
L
V
D
I
V
M
C
X
D
M
XX
D
I
X
C
V
M
C
...

result:

ok OK!

Test #80:

score: 0
Accepted
time: 3ms
memory: 4052kb

input:

9445
CXLXDVVXCMDCVCDMVMLDMICLDILVCCMMXCCILCDIMLLMXICVVCDLIMDDXLLXVCXLLVMIXXLCXVXXXMMLIXVLVXXMLICICDXVDVXDLMDXXCDCDDXDLICCLDDLVMCLVCIXCDMCDIXVVXILIVIDXDVICVIXMDMMCXVLLXXICMVCCLVVLIXILCMLXCVCXVXDIDIMLCVCLVVDCLMLCCDICVMDCDLVLXDVVMXLDLXMMDXCIDXIXICLXDXMLDIMVMMMIXCVVMLLXVLCIVVLVDIDMMCILCCVCVVLMDCCVVDXVLC...

output:

8543
C
X
L
X
D
V
V
X
C
M
D
C
V
C
D
M
V
M
L
D
M
I
C
L
D
I
L
V
CC
MM
X
CC
I
L
C
D
I
M
L
L
M
X
I
C
V
V
C
D
L
I
M
D
D
X
L
L
X
V
C
X
L
L
V
M
I
XX
L
C
X
V
XXX
MM
L
I
X
V
L
V
XX
M
L
I
C
I
C
D
X
V
D
V
X
D
L
M
D
XX
C
D
C
D
D
X
D
L
I
CC
L
D
D
L
V
M
C
L
V
C
I
X
C
D
M
C
D
I
X
V
V
X
I
L
I
V
I
D
X
D
V
I
C
V
I
X
M...

result:

ok OK!

Test #81:

score: 0
Accepted
time: 24ms
memory: 8040kb

input:

100000
VMMMIMXDVCVXLMLDLMMCLXCLCLCICMICLMCXMLICLDDLDMCCLVVLXCVDDDLMLCDLXCLLVLCIVIMMILILXCVXLDIVMDDDDVDLMXIDCLDICXCMMVIXCLXVDLVIMICMDCLXDLMDMVMLLLMMCCMLDMCMCVLCDVLMIIXMIICVMLDLVVXVXV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II
V
V
I
D
V
V
I
L
XX...

result:

ok OK!

Test #83:

score: 0
Accepted
time: 20ms
memory: 8072kb

input:

100000
VLMDLMXVDDCLXCLXXXLILDCLMDIXVLVLVCVMXCLLIXVLXIVIXCLIIMXXCILXMVCMMVDLXVDVCLCDDVMLCVLCCCDVVCCIIDXLXICCXXXVIMLLDXCVXDMMMXXMMDLXIXMCXVVIXICXCIVXIIIDXDMMDMMDCIDXCCMDILIVCDMMCLIMDMIIVLCVXVDDVCCIIIDLDCVLIIVCIIDMCCXDXVVCDLXMVCXIVLMVLLLDMCVCDDVVXIXVLIDDLVVDIMVDVLIDILMMVXDCMICICDLDIDXCCXLIDIVCLICCDDXMI...

output:

90530
V
L
M
D
L
M
X
V
D
D
C
L
X
C
L
XXX
L
I
L
D
C
L
M
D
I
X
V
L
V
L
V
C
V
M
X
C
L
L
I
X
V
L
X
I
V
I
X
C
L
II
M
XX
C
I
L
X
M
V
C
MM
V
D
L
X
V
D
V
C
L
C
D
D
V
M
L
C
V
L
CCC
D
V
V
CC
II
D
X
L
X
I
CC
XXX
V
I
M
L
L
D
X
C
V
X
D
MMM
XX
MM
D
L
XIX
M
C
X
V
V
I
X
I
CXC
I
V
X
III
D
X
D
MM
D
MM
D
C
I
D
X
CC
M
D...

result:

ok OK!

Test #84:

score: 0
Accepted
time: 20ms
memory: 8304kb

input:

100000
LDIILLVVDDXIXVXMVVLIVDMXIVXCDIDMDXXDIVMCDDLCLMDVCCMDDMCIVIMIVMILCDMCDIIILIDCIIXCILLCCDICMXXVVDIIICVMIVXLCMMDXDIVVCILVXMLXIVDMVCXLCXDMCXLMVMLCCLLLMVIVCXXCLVIVLIVCVXVXCCLLMCCVILIVICDDMIDLCMVXXDCXXDMMXVVDCCXICDLMCMXCLMIMDLDXIVXDILMVIXXDXMIDVMLDVLLVLIXIMVMIVLMMLLICXVDCIVIIVDIVIIVVVLIDILCIDCLMXXCI...

output:

90654
L
D
II
L
L
V
V
D
D
XIX
V
X
M
V
V
L
I
V
D
M
X
I
V
X
C
D
I
D
M
D
XX
D
I
V
M
C
D
D
L
C
L
M
D
V
CC
M
D
D
M
C
I
V
I
M
I
V
M
I
L
C
D
M
C
D
III
L
I
D
C
II
X
C
I
L
L
CC
D
I
C
M
XX
V
V
D
III
C
V
M
I
V
X
L
C
MM
D
X
D
I
V
V
C
I
L
V
X
M
L
X
I
V
D
M
V
C
X
L
C
X
D
M
C
X
L
M
V
M
L
CC
L
L
L
M
V
I
V
C
XX
C
L
V...

result:

ok OK!

Extra Test:

score: 0
Extra Test Passed