Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define ll long long
- #define ull unsigned long long
- #define nl cout<<"\n";
- #define sp cout<<" ";
- #define sz(x) x.size()
- #define NumOfDigit(w) log10(w) + 1
- #define fill(arr, val) memset(arr, val , sizeof(arr))
- #define PI 3.141592654
- #define ceil(w, m) (((w) / (m)) + ((w) % (m) ? 1 : 0))
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #define fi first
- #define se second
- #define cin(v) for (auto&i:v) cin >> i;
- #define cout(v) for (auto&i:v) cout << i << " ";
- #define fixed(n) fixed << setprecision(n)
- using namespace std;
- void zainab_hamdy(){
- ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
- //freopen("filename.in" , "r" ,stdin);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- bool prime(ll n){
- if(n==2 || n==3) return true;
- if(n<2 || n%2==0 ) return false;
- for(int i=3;i<=sqrt(n);i+=2) if(n%i==0) return false;
- return true;
- }
- void isAccepted(){
- string s ; cin >> s ;
- int n=sz(s) , total=abs(s[n-1] - s[0] ) ;
- char mn=min(s[0] , s[n-1]) , mx=max(s[0] , s[n-1]);
- vector < pair <char , int > > v ;
- for(int i=0 ; i<n ; i++) v.push_back({s[i] , i+1});
- sort(all(v));
- vector < int > ans;
- cout << total << ' ';
- if( s[0] <= s[n-1]){
- for(int i = 0 ; i<sz(v) ;i++)
- if (v[i].first >= s[0] and v[i].first <=s[n-1])
- ans.push_back(v[i].second);
- }else{
- for(int i = sz(v)-1 ; i>=0 ;i--)
- if (v[i].first >=s[n-1] and v[i].first <= s[0])
- ans.push_back(v[i].second);
- }
- cout << sz(ans) << '\n';
- for(auto& I : ans) cout << I << ' ';
- nl
- }
- int main(){
- zainab_hamdy();
- int testCase=1; // one test case
- cin >> testCase;
- while(testCase--)
- isAccepted(); // my code
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement