QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#782674#8048. Roman MasterLudovicaWA 39ms3652kbC++141.1kb2024-11-25 20:58:172024-11-25 20:58:24

Judging History

你现在查看的是最新测评结果

  • [2024-11-25 20:58:24]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:3652kb
  • [2024-11-25 20:58:17]
  • 提交

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]>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{
						ans=ans+2*k;
						k*=10;
						continue;
					} 
				}
				else{
					ans=ans+num[i]*k;
					k*=10;
					continue;
				}
			}
		}
		cout<<ans<<"\n";
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

3
II
IVI
VIIIIIV

output:

2
16
634

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 39ms
memory: 3652kb

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:

24222
2846
4284
22646
24424
54236
56346
42422
6428
8422
22244
54236
886
8464
8642
13426
3322
16326
4824
42244
3423
22664
2842
54636
6334
688
1863
14263
3463
8246
22642
4633
24246
52346
6633
8244
5238
46426
8666
1368
22226
44444
4228
2233
488
8244
6336
4248
44466
22666
3463
42222
3263
1328
884
1348
1...

result:

wrong answer 1st lines differ - expected: '5545557', found: '24222'