QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#656383#8048. Roman Masterucup-team4992#WA 21ms3668kbC++20893b2024-10-19 12:43:182024-10-19 12:43:20

Judging History

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

  • [2024-10-19 12:43:20]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:3668kb
  • [2024-10-19 12:43:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N=1e5+5;
string str;
int num[N];
int pos;

void solve(){
    cin>>str;
    int n=str.length(),res=0;
    pos=0;
    for(int i=n-1; i>=0; i--){
        if(str[i]=='V'){
            if(res==0) res=5;
            else{
                num[++pos]=res+5;
                res=0;
            }
        }else{
            if(res==4){
                num[++pos]=4;
                res=1;
            }
            else if(res==5) res--;
            else if(res==3){
                num[++pos]=3;
                res=1;
            }else res++;
        }
    }
    if(res) num[++pos]=res,res=0;
    for(int i=pos; i; i--) cout<<num[i];
    cout<<"\n";
    return;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.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: 3660kb

input:

3
II
IVI
VIIIIIV

output:

2
16
634

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 21ms
memory: 3668kb

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:

5610107
10846
1784
1010646
36109
6736
56496
11091010
6410610
841010
5101069
68106
86106
8464
61077
2376
34107
16476
4974
11089
13810
1010664
108410
9636
6334
6610610
1863
27710
34710
9746
10106410
47310
3746
7496
6633
91069
738
4776
8666
2106610
101010106
16669
1107610
5733
488
91069
6336
1748
16966...

result:

wrong answer 1st lines differ - expected: '5545557', found: '5610107'