QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#586229#8048. Roman MasterXiaoTie#WA 107ms3820kbC++171.1kb2024-09-24 09:13:352024-09-24 09:13:35

Judging History

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

  • [2024-09-24 09:13:35]
  • 评测
  • 测评结果:WA
  • 用时:107ms
  • 内存:3820kb
  • [2024-09-24 09:13:35]
  • 提交

answer

#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <algorithm>
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define bit(x) (1LL << x)
using namespace std;

typedef pair<int, int> PII;

void solve()
{
    string s;
    cin >> s;
    const int n = s.size();
    s = "?" + s;
    map<string, int> mp;
    mp["I"] = 1;
    mp["II"] = 2;
    mp["III"] = 3;
    mp["VI"] = 4;
    mp["V"] = 5;
    mp["IV"] = 6;
    mp["IIV"] = 7;
    mp["IIIV"] = 8;
    string t;
    int index = 1;
    int ans = 0;
    s[0] = '?';
    for (int i = n; i >= 0 ; i --) {
        string p = t + s[i];
        if (mp.count(p)) {
            t = p;
        }
        else {
            ans = ans + index * mp[t];
            index *= 10;
            while (t.size())
                t.pop_back();
            t += s[i];
        }
    }
    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    cin >> T;
    while (T--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
II
IVI
VIIIIIV

output:

2
16
634

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 107ms
memory: 3820kb

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
55846
1784
5555646
244554
6736
564546
45545555
6455545
845555
55555544
67456
74456
8464
54577
2376
34557
16476
45474
45744
13745
5555664
558455
54636
6334
5445545
1863
27645
34645
54746
55556455
46345
3746
74546
6633
5455544
738
4776
8666
1455445
555555556
44444
456445
5733
488
5455544
6336
...

result:

ok 100000 lines

Test #3:

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

input:

10000
VIVVIVIIIIIVVIIVIVVIVIIVVVIVIIVIIVIVVIIVVVIIIIVVIIIIIVVVVVVIIVVVIIVIIVVVIVVIIVIIIVIIIIIVVIIVIVVVVVVI
VVIVVVIIVIVVIVIIVVVVVVIVVIIIVIIIIVIVVIIIIIIVIVIIVVIVVIIVVIIVVIIIIIVVVVVIIVIIVVIIVIVVIVIVIIIVIVVIVVVI
VIVIVVVVIVVIIVVVIVIVVIVIIIIIIVVVVVVIVIVIIIVIIVIIIVVIVIVIVVIIIVIIVVVIVVVVVVVVVIIIVVIVIIIIIIVI...

output:

7501266988439940484
-3786831322035007280
-5541304228463724783
-1324748151217915136
-7529951791916831698
6639312257148834200
-400706810353376630
-6119351721141677913
-6281795221415005896
-495005317395415499
3118525758875138656
1255341890467937724
4894671602459137806
-1828345081206428386
5086897432845...

result:

wrong answer 1st lines differ - expected: '5466346446645676446458463455556457645547863464455556', found: '7501266988439940484'