QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#605740#9288. Roman Palindromeslym#WA 0ms3680kbC++201.5kb2024-10-02 19:18:312024-10-02 19:18:31

Judging History

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

  • [2024-10-02 19:18:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3680kb
  • [2024-10-02 19:18:31]
  • 提交

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 + 1 < 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 + 1 < 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 + 1 < 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 + 1 < 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
MMXXI

output:

3
MM
XX
I

result:

ok OK!

Test #2:

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

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: 3680kb

input:

1
X

output:

1
X

result:

ok OK!

Test #5:

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

input:

1
L

output:

1
L

result:

ok OK!

Test #6:

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

input:

1
C

output:

1
C

result:

ok OK!

Test #7:

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

input:

1
D

output:

1
D

result:

ok OK!

Test #8:

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

input:

1
M

output:

1
M

result:

ok OK!

Test #9:

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

input:

2
XX

output:

1
XX

result:

ok OK!

Test #10:

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

input:

2
LL

output:

2
L
L

result:

ok OK!

Test #11:

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

input:

3
XXX

output:

2
XX
X

result:

wrong answer Jury is better: 1 vs 2