QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#764806 | #6617. Encoded Strings I | wzq | WA | 0ms | 3844kb | C++14 | 1.2kb | 2024-11-20 10:45:54 | 2024-11-20 10:45:57 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'