QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#764850#6617. Encoded Strings IwzqWA 0ms3840kbC++141.8kb2024-11-20 10:56:012024-11-20 10:56:08

Judging History

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

  • [2024-11-20 10:56:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-11-20 10:56:01]
  • 提交

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++;
        }
    }
    bool ok = 0;
    string tmp = s.substr(0,en);
    int op = en;
    for(int i = en;i<n;i++)
    {
        if(ok&&s[i]!=tmp[0])break;
        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)
            {
                ok = 1;
                op+=en;
                i = j-1;
            }
            else{
                break;
            }
        }
    }


    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;
}

詳細信息

Test #1:

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

input:

4
aacc

output:

bbaa

result:

ok single line: 'bbaa'

Test #2:

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

input:

3
aca

output:

ba

result:

ok single line: 'ba'

Test #3:

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

input:

1
t

output:

a

result:

ok single line: 'a'

Test #4:

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

input:

12
bcabcabcbcbb

output:

cbacba

result:

ok single line: 'cbacba'

Test #5:

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

input:

1000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok single line: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'

Test #6:

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

input:

1000
ggkkkggggggkgggkgkgkkkkkggkkkgggkgkgggkkgkkgkgkgkgkgggkgkkkkgkgkkgkggkgggkgggkgkkgggggkkgkgkkkkgkkkkkkgkkggkkkkggkkkgkgggkggkkgkkgkgggkkggggkkggggkggkkggkgkgkgkkkgkkgkgkkgkkgkgkggkgggkgkkkgkkkgkkggkkggkkgkgkgkkkkkgkkggkgggkkkkgggkggkgggkkkgkkkkggggkkggkkkkgkkggkkkkkkgkgggkkkkkgggggggkgggkkkggkg...

output:

bbaaa

result:

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