QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#605746#9288. Roman Palindromeslym#WA 0ms3876kbC++201.5kb2024-10-02 19:21:242024-10-02 19:21:25

Judging History

This is the latest submission verdict.

  • [2024-10-02 19:21:25]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3876kb
  • [2024-10-02 19:21:24]
  • Submitted

answer

#include<bits/stdc++.h>
using i64 = long long;

void solve() {
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	std::vector<std::string > ans;
	int num = 0;
 	for (int i = 0; i < n; i ++) {
 		if (s[i] == 'M') {
 			int j = i;
 			std::string t = "";
 			while (j < n && j - i < 3 && s[j] == 'M') {
 				t += 'M';
 				j ++;
 			}
 			i = j - 1;
 			num ++;
 			ans.push_back(t);
 		} else if (s[i] == 'C') {
 			int j = i;
 			std::string t = "";
 			while (j < n && j - i < 3 && s[j] == 'C') {
 				t += 'C';
 				j ++;
 			}
 			i = j - 1;
 			num ++;
 			ans.push_back(t);
 		} else if (s[i] == 'D') { 
 			num ++;
 			ans.push_back("D");
 		} else if (s[i] == 'X') {
			int j = i;
 			std::string t = "";
 			while (j < n && j - i < 3 && s[j] == 'X') {
 				t += 'X';
 				j ++;
 			}
 			i = j - 1;
 			num ++;
 			ans.push_back(t);
 		} else if (s[i] == 'L') {
 			num ++;
 			ans.push_back("L");
 		} else if (s[i] == 'I') {
			int j = i;
 			std::string t = "";
 			while (j < n && j - i < 3 && s[j] == 'I') {
 				t += 'I';
 				j ++;
 			}
 			i = j - 1;
 			num ++;
 			ans.push_back(t);
 		} else if (s[i] == 'V') {
 			num ++;
 			ans.push_back("V");
 		} 
	}
	std::cout << ans.size() << '\n';
	for (auto it : ans) {
		std::cout << it << '\n';
	}
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int t = 1;
	//std::cin >> t;
	while (t --) {
		solve();
	}
	return 0;
}

详细

Test #1:

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

input:

5
MMXXI

output:

3
MM
XX
I

result:

ok OK!

Test #2:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

1
I

output:

1
I

result:

ok OK!

Test #3:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

1
V

output:

1
V

result:

ok OK!

Test #4:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

1
X

output:

1
X

result:

ok OK!

Test #5:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

1
L

output:

1
L

result:

ok OK!

Test #6:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

1
C

output:

1
C

result:

ok OK!

Test #7:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

1
D

output:

1
D

result:

ok OK!

Test #8:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1
M

output:

1
M

result:

ok OK!

Test #9:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

2
XX

output:

1
XX

result:

ok OK!

Test #10:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

2
LL

output:

2
L
L

result:

ok OK!

Test #11:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

3
XXX

output:

1
XXX

result:

ok OK!

Test #12:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

3
VVV

output:

3
V
V
V

result:

ok OK!

Test #13:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

4
MMMM

output:

2
MMM
M

result:

ok OK!

Test #14:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

4
DDDD

output:

4
D
D
D
D

result:

ok OK!

Test #15:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

5
CCCCC

output:

2
CCC
CC

result:

ok OK!

Test #16:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

5
DDDDD

output:

5
D
D
D
D
D

result:

ok OK!

Test #17:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

6
IIIIII

output:

2
III
III

result:

ok OK!

Test #18:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

6
VVVVVV

output:

6
V
V
V
V
V
V

result:

ok OK!

Test #19:

score: -100
Wrong Answer
time: 0ms
memory: 3644kb

input:

3
XIX

output:

3
X
I
X

result:

wrong answer Jury is better: 1 vs 3