Submission
Status:
[PPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Kei
Problemset: เรียงสตริง
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-07 17:24:32
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve(){
string s;
cin >> s;
sort(s.begin(),s.end());
for(int i=0;i<s.size()-1;i++){
if(s[i]==s[i+1]){
int j=i;
while(j<(int)s.size() && s[j]==s[i]) j++;
s.erase(i,1); // now we only remove the duplicate, leaving 1
i--;
}
}
for(char& c : s){
cout << c << ' ';
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}