QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#764806#6617. Encoded Strings IwzqWA 0ms3844kbC++141.2kb2024-11-20 10:45:542024-11-20 10:45:57

Judging History

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

  • [2024-11-20 10:45:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2024-11-20 10:45:54]
  • 提交

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++;
        }
    }
    for(int i = 0;i<en;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: 3516kb

input:

4
aacc

output:

bbaa

result:

ok single line: 'bbaa'

Test #2:

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

input:

3
aca

output:

ba

result:

ok single line: 'ba'

Test #3:

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

input:

1
t

output:

a

result:

ok single line: 'a'

Test #4:

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

input:

12
bcabcabcbcbb

output:

cba

result:

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