Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define pb push_back
- int main()
- {
- _test
- {
- int n;
- cin>>n;
- vector<string> s(n);
- for(auto &e: s) cin>>e;
- int ans = 0;
- vector<char> v;
- for(int i=0; i<n/2; i++)
- {
- for(int j=0; j<n/2; j++)
- {
- v.clear();
- v.pb(s[i][j]);
- v.pb(s[j][n-i-1]);
- v.pb(s[n-i-1][n-j-1]);
- v.pb(s[n-j-1][i]);
- sort(v.begin(), v.end());
- for(auto e: v)
- ans += v.back() - e;
- }
- }
- cout<<ans<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment