QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#764827#6617. Encoded Strings IwzqWA 0ms3864kbC++141.6kb2024-11-20 10:51:502024-11-20 10:51:58

Judging History

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

  • [2024-11-20 10:51:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3864kb
  • [2024-11-20 10:51:50]
  • 提交

answer

#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define int long long
typedef long long ll; 

const int N = 1e5+10;
const int mod = 998244353;


void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    map<char,int>mp;
    map<char,char>mmp;
    int en = n;
    for(int i = 0;i<n;i++)
    {
        if(mp[s[i]]==0)
        {
            mp[s[i]]=1;
        }
        else if(mp[s[i]]==1)
        {
            if(s[i]!=s[i-1])
            {
                en = i;
                break;
            }
        }
    }
    int cnt = 0;
    for(int i = en-1;i>=0;i--)
    {
        if(i==en-1)
        {
            mmp[s[i]] = 'a'+cnt;
            cnt++;
            continue;
        }
        if(s[i]!=s[i+1])
        {
            mmp[s[i]] = 'a'+cnt;
            cnt++;
        }
    }

    string tmp = s.substr(0,en);
    int op = en;
    for(int i = en;i<n;i++)
    {
        if(s[i]==tmp[0])
        {
            int j = i;
            int cnt = 0;
            while(j<n&&cnt<en&&s[j]==tmp[cnt])
            {
                j++;
                cnt++;
            }
            if(cnt>=en)
            {
                op+=en;
            }
        }
    }


    for(int i = 0;i<op;i++)
    {
        cout<<mmp[s[i]];
    }




    return;
}
signed main(){
    int _ = 1;
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
    //cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
aacc

output:

bbaa

result:

ok single line: 'bbaa'

Test #2:

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

input:

3
aca

output:

ba

result:

ok single line: 'ba'

Test #3:

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

input:

1
t

output:

a

result:

ok single line: 'a'

Test #4:

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

input:

12
bcabcabcbcbb

output:

cbacba

result:

ok single line: 'cbacba'

Test #5:

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

input:

1000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok single line: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'

Test #6:

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

input:

1000
ggkkkggggggkgggkgkgkkkkkggkkkgggkgkgggkkgkkgkgkgkgkgggkgkkkkgkgkkgkggkgggkgggkgkkgggggkkgkgkkkkgkkkkkkgkkggkkkkggkkkgkgggkggkkgkkgkgggkkggggkkggggkggkkggkgkgkgkkkgkkgkgkkgkkgkgkggkgggkgkkkgkkkgkkggkkggkkgkgkgkkkkkgkkggkgggkkkkgggkggkgggkkkgkkkkggggkkggkkkkgkkggkkkkkkgkgggkkkkkgggggggkgggkkkggkg...

output:

bbaaabbbbbbabbbababaaaaabbaaabbbababbbaabaabababababbbabaaaababaababbabbbabbbabaabbbbbaababaaaabaaaaaabaabbaaaabbaaababbbabbaabaababbbaabbbbaabbbbabbaabbabababa

result:

wrong answer 1st lines differ - expected: 'bbaaabbbbbbabbbababaaaaabbaaab...bbbbabbabababaabbbbbababaababaa', found: 'bbaaabbbbbbabbbababaaaaabbaaab...babbbaabbbbaabbbbabbaabbabababa'