QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#782732 | #8048. Roman Master | Ludovica | WA | 39ms | 3632kb | C++14 | 1.3kb | 2024-11-25 21:10:59 | 2024-11-25 21:10:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+1;
string s;
int T,num[N],ans;
signed main(){
cin>>T;
while(T--){
cin>>s;
ans=0;
for(int i=0;i<s.length();i++){
if(s[i]=='I') num[i]=1;
else num[i]=5;
}
int k=1;
for(int i=s.length();i>=0;i--){
if(num[i]==0) continue;
if((num[i]!=0&&num[i-1]==0)||i==0){
ans=ans+num[i]*k;
k*=10;
continue;
}
if(num[i]==5&&num[i-1]!=1&&num[i+1]!=1){
ans=ans+5*k;
k*=10;
continue;
}
if(num[i]>num[i-1]&&num[i-1]!=0){
ans=ans+4*k;
num[i-1]=0;
k*=10;
continue;
}
else if(num[i]<num[i-1]&&num[i-1]!=0){
ans=ans+6*k;
num[i-1]=0;
k*=10;
continue;
}
else{
if(num[i]==num[i-1]==1){
num[i-1]=0;
if(num[i-2]==1) {
if(num[i-3]==5){
ans=ans+8*k;
k*=10;
num[i-3]=num[i-2]=0;continue;
}
else{
ans=ans+3*k;
k*=10;
num[i-2]=0;continue;
}
}
else if(num[i-2]==5){
ans=ans+7*k;
k*=10;
num[i-2]=0;continue;
}
else if(num[i-2]==0){
ans=ans+2*k;
k*=10;
continue;
}
}
else{
ans=ans+num[i]*k;
k*=10;
continue;
}
}
}
cout<<ans<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
3 II IVI VIIIIIV
output:
2 16 634
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 39ms
memory: 3632kb
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: 14ms
memory: 3632kb
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'