QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#610043 | #8048. Roman Master | yimg# | WA | 27ms | 3780kb | C++20 | 991b | 2024-10-04 14:47:16 | 2024-10-04 14:47:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void work()
{
string s;
cin >> s;
deque<int> ans;
for(int i = s.length() - 1; i >= 0; --i){
if(s[i] == 'V'){
if(i && s[i - 1] == 'I'){
ans.push_front(4);
i--;
}
else{
ans.push_front(5);
}
}
else if(s[i] == 'I'){
if(i >= 3 && s[i - 1] == 'I' && s[i - 2] == 'I' && s[i - 3] == 'V'){
ans.push_front(8);
i -= 3;
}
else if(i >= 2 && s[i - 1] == 'I' && s[i - 2] == 'I'){
ans.push_front(3);
i -= 2;
}
else if(i >= 2 && s[i - 1] == 'I' && s[i - 1] == 'V'){
ans.push_front(7);
i -= 2;
}
else if(i && s[i - 1] == 'I'){
ans.push_front(2);
i--;
}
else if(i && s[i - 1] == 'V'){
ans.push_front(6);
i--;
}
else{
ans.push_front(1);
}
}
}
for(auto i : ans){
cout << i;
}
cout << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--)
work();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3780kb
input:
3 II IVI VIIIIIV
output:
2 16 634
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 27ms
memory: 3600kb
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:
55455552 55846 4284 5555646 244554 54236 564546 45545555 6455545 845555 55555544 542456 524456 8464 545642 13426 345552 164526 454524 455244 34245 5555664 558455 54636 6334 5445545 1863 142645 34645 545246 55556455 46345 24246 524546 6633 5455544 5238 46426 8666 1455445 555555556 44444 456445 55233 ...
result:
wrong answer 1st lines differ - expected: '5545557', found: '55455552'