QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#769811#6617. Encoded Strings Ilonelywolf#WA 0ms3672kbC++20679b2024-11-21 19:28:132024-11-21 19:28:13

Judging History

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

  • [2024-11-21 19:28:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3672kb
  • [2024-11-21 19:28:13]
  • 提交

answer

#include <bits/stdc++.h>  
using namespace std;  

#define int long long  

signed main() {  
    ios::sync_with_stdio(false);
    cin.tie(nullptr);  

	int n;
	cin >> n;

	string s;
	cin >> s;

	s = s;

	int cnt[26] {};
	int mp[26] {};
	for (int i = n - 1; i >= 0; i--) {
		if (!cnt[s[i] - 'a']) {
			for (int j = 0; j < 26; j++) {
				if (cnt[j]) {
					mp[s[i] - 'a']++;
				}
			}
		}
		cnt[s[i] - 'a']++;
	}


	for (auto &c : s) {
		c = 'a' + mp[c - 'a'];
	}

	vector<string> a(n);
	for (int i = 0; i < n; i++) {
		a[i] = string(s.begin() + i, s.end());
	}

	sort(a.begin(), a.end());
	cout << a[n - 1] << "\n";

    return 0;
}  

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
aacc

output:

bbaa

result:

ok single line: 'bbaa'

Test #2:

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

input:

3
aca

output:

ba

result:

ok single line: 'ba'

Test #3:

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

input:

1
t

output:

a

result:

ok single line: 'a'

Test #4:

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

input:

12
bcabcabcbcbb

output:

cabcababaa

result:

wrong answer 1st lines differ - expected: 'cbacba', found: 'cabcababaa'