QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#152437 | #6617. Encoded Strings I | LFCode# | WA | 1ms | 4044kb | C++14 | 1.8kb | 2023-08-28 08:30:12 | 2023-08-28 08:30:12 |
Judging History
answer
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#define DEBUG(x) std::cerr << #x << " = " << x << std::endl;
#define forall(G, i_) for (int i_ = 0, __for_siz__ = (int) G.size(); i_ < __for_siz__; ++i_)
#define ALL(x) (x).begin(), (x).end()
typedef long long int lli;
using std::cin;
using std::cout;
using std::endl;
inline int read() {
int s = 0, x = 1; char ch = getchar();
while (!isdigit(ch)) { if (ch == '-') x = -x; ch = getchar(); }
while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); }
return s * x;
}
inline int readll() {
long long int s = 0, x = 1; char ch = getchar();
while (!isdigit(ch)) { if (ch == '-') x = -x; ch = getchar(); }
while (isdigit(ch)) { s = s * 10ll + ch - '0'; ch = getchar(); }
return s * x;
}
const int MAXCH = 20 + 2;
const int MAXN = 1000 + 10;
int n;
char sss[MAXN];
int calc[MAXCH];
int g[MAXCH];
std::vector<std::string> resss;
void encode(char *ss) {
int len = strlen(ss);
memset(g, 0, sizeof g);
for (int i = 0; i < 21; ++i) {
// calc G(s);
memset(calc, 0, sizeof calc);
for (int j = len - 1; j >= 0; --j) {
if (ss[j] - 'a' == i) break;
calc[ss[j] - 'a']++;
}
for (int j = 0; j < 21; ++j) {
g[i] += (calc[j] != 0);
}
}
std::string res;
for (int i = 0; i < len; ++i) res += g[ss[i] - 'a'] + 'a';
resss.push_back(res);
}
int main() {
scanf("%d", &n); scanf("%s", sss);
int len = strlen(sss);
for (int i = 0; i < len; ++i) {
encode(sss + i);
} std::sort(resss.begin(), resss.end());
printf("%s\n", resss[resss.size() - 1].c_str());
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3740kb
input:
4 aacc
output:
bbaa
result:
ok single line: 'bbaa'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
3 aca
output:
ba
result:
ok single line: 'ba'
Test #3:
score: 0
Accepted
time: 1ms
memory: 4044kb
input:
1 t
output:
a
result:
ok single line: 'a'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3692kb
input:
12 bcabcabcbcbb
output:
cabcababaa
result:
wrong answer 1st lines differ - expected: 'cbacba', found: 'cabcababaa'