QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#741428#8048. Roman MasterCORRECT#WA 39ms3816kbC++201.1kb2024-11-13 14:21:052024-11-13 14:21:10

Judging History

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

  • [2024-11-13 14:21:10]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:3816kb
  • [2024-11-13 14:21:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

void work() {
    string s;
    cin >> s;
    int num = 0;
    vector<int> ans;
    for (int i=s.size()-1; i>=0; i--) {
        if (s[i] == 'I') {
            num ++;  continue;
        }
        if (num == 0 && i && s[i-1] == 'I') {
            num = -1;
            ans.push_back(4);
            continue;
        }
        int d = num % 3;
        if (d == 0)  d = 3;
        num -= d;
        while (num) {
            ans.push_back(min(num, 3));
            num -= min(num, 3);
        }
        ans.push_back(5 + d);
    }
    while (num) {
        ans.push_back(min(num, 3));
        num -= min(num, 3);
    }
    for (int i=ans.size()-1; i>=0; i--) {
        cout << ans[i];
    }
    cout << '\n';
}
int main()
{
    #ifdef QHK
    freopen("qi.in","r",stdin);
    freopen("qi.out","w",stdout);
    #endif
    ios::sync_with_stdio(false); cin.tie(0); 
    int T=1;
    cin >> T;
    while(T--) {
        work();
    }

   return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
II
IVI
VIIIIIV

output:

2
16
634

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 39ms
memory: 3544kb

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:

8-38-348-38-38-37
8-38-3846
1784
8-38-38-38-3646
2448-38-34
6736
8-3648-346
48-38-348-38-38-38-3
648-38-38-348-3
848-38-38-38-3
8-38-38-38-38-38-344
6748-36
7448-36
8464
8-348-377
2376
348-38-37
16476
48-3474
48-3744
13748-3
8-38-38-38-3664
8-38-3848-38-3
8-34636
6334
8-3448-38-348-3
1863
27648-3
34...

result:

wrong answer 1st lines differ - expected: '5545557', found: '8-38-348-38-38-37'