QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#735578#8048. Roman Masteroqmsac#WA 23ms3628kbC++231.3kb2024-11-11 20:48:322024-11-11 20:48:34

Judging History

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

  • [2024-11-11 20:48:34]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:3628kb
  • [2024-11-11 20:48:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define N 1000005
#define M 998244353
#define ll long long

#define pii pair<ll,ll>
ll f[N];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    ll T;
    cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        s=" "+s;
        ll l=s.length();
        for(int i=1;i<l;i++)
        {
            if(s[i]=='I') {
                f[i] = f[i - 1] * 10 +1;
                if(s[i-1]=='V')
                {
                    f[i]=min(f[i],f[i-2]*10+6);
                }
                else if(s[i-1]=='I')
                {
                    f[i]=min(f[i],f[i-2]*10+2);
                    if(s[i-2]=='V')
                    {
                        f[i]=min(f[i],f[i-3]*10+7);
                    }
                    else if(s[i-1]=='I')
                    {
                        f[i]=min(f[i],f[i-3]*10+3);
                    }
                }
            }
            else if(s[i]=='V')
            {
                f[i] = f[i - 1] * 10 +5;
                if(s[i-1]=='I')
                {
                    f[i]=min(f[i],f[i-2]*10+4);
                }
            }
        }
        cout<<f[l-1]<<endl;
    }
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3560kb

input:

3
II
IVI
VIIIIIV

output:

2
16
634

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 23ms
memory: 3628kb

input:

100000
VVIVVVVVII
VVVIIIIVVI
IVIIVIIIIV
VVVVVIIVVI
IIIVIVVVIV
VIVIIIIIVI
VVIIVVIVVI
IVVVIVVVVV
VIIVVVVIVV
VIIIIVVVVV
VVVVVVIVIV
VIVIIIVVVI
VIIIVIVVVI
VIIIIVVIIV
VIVVVIIVII
IIIIIVIIVI
IIIIVVVVII
IVIIVVIIVI
IVVIVVIIIV
IVVVIIIVIV
IIIIVIIIVV
VVVVVIVIIV
VVVIIIIVVV
VIVVIIIIVI
VIIIIIIIIV
VIVIVVVIVV
IVIIIVI...

output:

5545557
555346
16434
5555646
244554
6736
564546
45545555
6455545
5345555
55555544
67456
74456
53464
54577
2376
34557
16476
45474
45744
13745
5555664
5553455
54636
6334
5445545
4363
27645
34645
54746
55556455
46345
3746
74546
6633
5455544
6343
4776
53666
1455445
555555556
44444
456445
5733
4743
54555...

result:

wrong answer 2nd lines differ - expected: '55846', found: '555346'