QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212203 | #6617. Encoded Strings I | chitoge | WA | 0ms | 3636kb | C++20 | 1.1kb | 2023-10-13 11:32:22 | 2023-10-13 11:32:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int c[1005][30];
vector<int> mp;
int vis[30];
int main (){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n;cin>>n;
string s;cin>>s;
vector<string> ans(n);
for(int i=0;i<n;i++){
if(vis[s[i]-'a']){
for(int j=0,f=0,k=mp.size();j<mp.size();j++,k--){
if(mp[j]==s[i]-'a'){
f=1;
}
if(f){
if(j==mp.size()-1){
mp[j]=s[i]-'a';
c[i][mp[j]]=1;
break;
}
c[i][mp[j+1]]=k;
}else{
c[i][mp[j]]=k;
}
}
}else{
vis[s[i]-'a']=1;
mp.emplace_back(s[i]-'a');
for(int j=0;j<mp.size();j++){
c[i][mp[j]]=mp.size()-j;
}
}
// cout<<"SDHUDSH0 "<<i<<endl;
// for(int t=0;t<mp.size();t++){
// cout<<(mp[t]);
// }cout<<endl;
// for(int t=0;t<mp.size();t++){
// cout<<(c[i][mp[t]]);
// }cout<<endl;
for(int j=0;j<=i;j++){
ans[i].push_back('a'+c[i][s[j]-'a']-1);
}
}
sort(ans.begin(),ans.end(),greater<string>());
cout<<ans[0]<<endl;
// for(int i=0;i<ans.size();i++){
// // cout<<ans[i]<<endl;
// }
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
input:
4 aacc
output:
bbaa
result:
ok single line: 'bbaa'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
3 aca
output:
ba
result:
ok single line: 'ba'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
1 t
output:
a
result:
ok single line: 'a'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3628kb
input:
12 bcabcabcbcbb
output:
cba
result:
wrong answer 1st lines differ - expected: 'cbacba', found: 'cba'