题目
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 1e6 + 5, d = 500;
vector<string> vec[6];
int mp[1005];
signed main(){int n;cin >> n;for(int i = 1; i <= n; i++){string s;cin >> s;int len = s.size();vec[len].push_back(s);}int res = 0;for(int i = 1; i <= 5; i++){for(int j = 1; j <= 5; j++){if((i + j) % 2 == 1) continue;memset(mp, 0, sizeof(mp));for(auto s : vec[i]){int x = 0;for(int k = 0; k < i; k++){if(k < (i + j) / 2){x += s[k] - '0';}else{x -= s[k] - '0';}}mp[x + d]++;}for(auto s : vec[j]){int x = 0;for(int k = 0; k < j; k++){if(k < (i + j) / 2){x += s[j - 1 - k] - '0';}else{x -= s[j - 1 - k] - '0';}}res += mp[x + d];}}}cout << res;return 0;
}