QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#643191#6617. Encoded Strings IxzinWA 0ms3572kbC++14751b2024-10-15 19:39:452024-10-15 19:39:46

Judging History

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

  • [2024-10-15 19:39:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3572kb
  • [2024-10-15 19:39:45]
  • 提交

answer

#include <bits/stdc++.h>

#define N 1010
using namespace std;

string s;
string t;
int n, r, mx;
bool v[300];
int a[N], sum, p;
int main() {
    cin>>n; r = n;
    cin>>s; s = " " + s + " ";
    for(int i = 1;i <= r; i++) {
        memset(v, 0, sizeof(v));
        sum = 0; mx = 0; v[s[i]] = 1; s[r + 1] = s[i];
        for(int j = i + 1; j <= r + 1; j++) {
            if(v[s[j] ]== 0) sum++, v[s[j]] = 1;
            if(s[j] == s[i]) {
                a[j] = sum; sum = 0;
                memset(v, 0, sizeof(v));
                if(a[mx] <= a[j]) mx  = j;
                v[s[j]] = 1;
            }
            
        }
        t += char('a' + a[mx]); 
        r = mx - 1;
    }
    cout<<t<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
aacc

output:

bbaa

result:

ok single line: 'bbaa'

Test #2:

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

input:

3
aca

output:

ba

result:

ok single line: 'ba'

Test #3:

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

input:

1
t

output:

a

result:

ok single line: 'a'

Test #4:

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

input:

12
bcabcabcbcbb

output:

ccba

result:

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