QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#776329 | #8048. Roman Master | 22016020736 | WA | 32ms | 4072kb | C++17 | 2.7kb | 2024-11-23 18:15:06 | 2024-11-23 18:15:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
char s[200009];
deque<int>ans;
void zhixin(int len)
{
if(len%3==0)
{
while(len)
{
len-=3;
ans.push_back(3);
}
}
else if(len%3==1)
{
len--;
ans.push_back(1);
while(len)
{
len-=3;
ans.push_back(3);
}
}
else
{
len-=2;
ans.push_back(2);
while(len)
{
len-=3;
ans.push_back(3);
}
}
}
int main()
{
int tt=0;
scanf("%d",&tt);
while(tt--)
{
///vector<int>ans;
ans.clear();
scanf(" %s",s+1);
int n=strlen(s+1);
int po=n;
while(po>=1)
{
int tmp=po;
if(s[tmp]=='V')
{
if(tmp-1>=1&&s[tmp-1]=='I')
{
ans.push_front(4);
po=po-2;
}
else ans.push_front(5),po=po-1;
}
else
{
while(tmp>=1)
{
if(s[tmp]=='V') break;
tmp--;
}
if(tmp==0)
{
//po=tmp;
int len=po;
while(len>=3)
{
ans.push_front(3);
len-=3;
}
po=0;
if(len==1) ans.push_front(1);
else if(len==2) ans.push_back(2);
}
else
{
int len=po-tmp;
while(len>3)
{
len-=3;
ans.push_front(3);
}
if(len==0) po=tmp;
else if(len==1)
{
ans.push_front(6);
po=tmp-1;
}
else if(len==2)
{
ans.push_front(7);
po=tmp-1;
}
else
{
ans.push_front(8);
po=tmp-1;
}
}
}
}
while(!ans.empty())
{
int tmp=ans.front();
ans.pop_front();
printf("%d",tmp);
}
printf("\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4056kb
input:
3 II IVI VIIIIIV
output:
2 16 634
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 32ms
memory: 4072kb
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 445542 6736 564546 45545555 6455545 845555 55555544 67456 74456 8464 54577 3762 34557 16476 45474 45744 13745 5555664 558455 54636 6334 5445545 1863 76452 34645 54746 55556455 46345 3746 74546 6633 5455544 738 4776 8666 1455445 555555556 44444 456445 5733 488 5455544 6336 ...
result:
wrong answer 5th lines differ - expected: '244554', found: '445542'