QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#782744 | #8048. Roman Master | Coffins | WA | 0ms | 3576kb | C++14 | 983b | 2024-11-25 21:14:04 | 2024-11-25 21:14:15 |
Judging History
answer
#include<bits/stdc++.h>
#define All(x) x.begin(),x.end()
using namespace std;
using ull=unsigned long long;
using ll=long long;
using bint=__int128;
using ld=long double;
using pii=pair<int,int>;
using vi=vector<int>;
const int N=1e5+5;
int n;char s[N];
int pr[N],ls[N],c[N];
void solve()
{
cin>>s+1;n=strlen(s+1);int ps=0;
for(int i=1;i<=n;i++)
{if(s[i]=='V')ps=i;pr[i]=ps;}
for(int i=1;i<=n;i++)
{
if(pr[i]<=i-4)ls[i]=n-3,c[i]=3;
else if(!pr[i])ls[i]=0,c[i]=i;
else if(pr[i]==i-3)ls[i]=i-4,c[i]=8;
else if(pr[i]==i-2)ls[i]=i-3,c[i]=7;
else if(pr[i]==i-1)ls[i]=i-2,c[i]=6;
else if(s[i-1]=='I')ls[i]=i-2,c[i]=4;
else ls[i]=i-1,c[i]=5;
}vector<int> vc;int s=n;
while(s)vc.push_back(c[s]),s=ls[s];
reverse(All(vc));for(int c:vc)
cout<<c;cout<<'\n';
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;cin>>t;while(t--)solve();return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3576kb
input:
3 II IVI VIIIIIV
output:
2 16 834
result:
wrong answer 3rd lines differ - expected: '634', found: '834'