QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#522750 | #8048. Roman Master | zzhi | WA | 134ms | 3632kb | C++14 | 946b | 2024-08-17 13:10:11 | 2024-08-17 13:10:11 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
map<string,int> p;
int a[1000006];
signed main(){
// ios::sync_with_stdio(false);
// cin.tie(0);cout.tie(0);
int t;
cin>>t;
p.clear();
p["I"]=1;
p["II"]=2;
p["III"]=3;
p["IV"]=4;
p["V"]=5;
p["VI"]=6;
p["VII"]=7;
while(t--){
string s;
int cnt=0;
cin>>s;
int len=s.size();
for(int i=len-1;i>=0;){
int tem=1;
int ans=0;
while(i-tem+1>=0&&p[s.substr(i-tem+1,tem)]!=0){
ans=p[s.substr(i-tem+1,tem)];
tem++;
// cout<<1<<endl;
}
a[++cnt]=ans;
i=i-tem+1;
// cout<<2<<endl;
}
for(int i=cnt;i>=1;--i){
cout<<a[i];
}
cout<<endl;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
3 II IVI VIIIIIV
output:
2 16 634
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 134ms
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 555346 16434 5555646 244554 6736 564546 45545555 6455545 5345555 55555544 67456 74456 53464 54577 2376 34557 16476 45474 45744 13745 5555664 5553455 54636 6334 5445545 4363 27645 34645 54746 55556455 46345 3746 74546 6633 5455544 6343 4776 53666 1455445 555555556 44444 456445 5733 4743 54555...
result:
wrong answer 2nd lines differ - expected: '55846', found: '555346'