Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- using ld = long double;
- int main()
- {
- string al(26, 'a');
- iota(al.begin(), al.end(), 65);
- al += " '";
- ld dp = 60 / 28;
- ll n;
- cin >> n;
- while (n-- > 0)
- {
- string x;
- ll sum = 0;
- getline(cin, x);
- ll p = al.find(x.at(0));
- ll ps;
- for (int i = 1; i < x.size(); i++)
- {
- ps = al.find(x.at(i));
- sum += min(abs(p - ps), 60 - abs(p - ps));
- p = ps;
- }
- cout << sum << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment