QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#586227#8048. Roman MasterXiaoTie#WA 108ms3764kbC++171.2kb2024-09-24 09:06:362024-09-24 09:06:38

Judging History

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

  • [2024-09-24 09:06:38]
  • 评测
  • 测评结果:WA
  • 用时:108ms
  • 内存:3764kb
  • [2024-09-24 09:06:36]
  • 提交

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;
    for (int i = n; i >= 1 ; i --) {
        t += s[i];
        if (mp.find(t) != mp.end() && i != 1) {
            continue;
        }
        else {
            if (mp.find(t) == mp.end()) {
                i ++;
                t.pop_back();
            }
            ans = ans + index * mp[t];
            index *= 10;
            while (t.size())
                t.pop_back();
        }
    }
    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: 3540kb

input:

3
II
IVI
VIIIIIV

output:

2
16
634

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 108ms
memory: 3764kb

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: 61ms
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'