QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212203#6617. Encoded Strings IchitogeWA 0ms3636kbC++201.1kb2023-10-13 11:32:222023-10-13 11:32:23

Judging History

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

  • [2023-10-13 11:32:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2023-10-13 11:32:22]
  • 提交

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'