QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#769811 | #6617. Encoded Strings I | lonelywolf# | WA | 0ms | 3672kb | C++20 | 679b | 2024-11-21 19:28:13 | 2024-11-21 19:28:13 |
Judging History
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'