fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int arr[26];
  4. int main() {
  5. ios::sync_with_stdio(0);
  6. cin.tie(0);
  7. for(int i = 0; i < 26; i++) {
  8. arr[i] = -1;
  9. }
  10. string s;
  11. cin >> s;
  12. for(int i = 0; i < s.length(); i++) {
  13. arr[s[i]-'a'] = i;
  14. }
  15. for(int i = 0; i < 26; i++) {
  16. cout << arr[i] << ' ';
  17. }
  18. }
Success #stdin #stdout 0s 5348KB
stdin
baekjoon
stdout
1 0 -1 -1 2 -1 -1 -1 -1 4 3 -1 -1 7 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1