Please read the new rule regarding the restriction on the use of AI tools. ×

Jumping on Tiles

Revision en1, by ehs025, 2022-09-14 21:54:57
#include<bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--) {
        string str;
        cin>>str;
        vector<int> arr[26];
        for(int i=0;i<str.size();i++) {
            arr[str[i] - 'a'].push_back(i);
        }
        int start=str[0] - 'a',end=str.back() - 'a';
        vector<int> ans;
        for(int i=start;;i<=end?i++:i--) {
            for(auto j:arr[i]) ans.push_back(j+1);
            if(i==end) break;
        }
        cout << abs(end-start) << ' ' << ans.size() << endl;
        for(auto n:ans) {
            cout << n << ' ';
        }
        cout << endl;
    }
}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English ehs025 2022-09-14 21:54:57 677 Initial revision (published)