Submission #496475

#TimeUsernameProblemLanguageResultExecution timeMemory
496475AkiYuuPIN (CEOI10_pin)C++17
70 / 100
181 ms5932 KiB
#include <bits/stdc++.h> #define ll long long //debug using namespace std; string s[50001]; ll giong[5]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,D; cin >> n >> D; for (int i = 1; i <= n; i++) cin >> s[i]; for (int mask = 0; mask < (1 << 4); mask++) { map<string,int> mp; mp.clear(); int cnt = __builtin_popcount(mask); for (int i = 1; i <= n; i++) { string tmp; for (int j = 0; j < 4; j++) if (mask & (1 << j)) tmp = tmp + s[i][j]; mp[tmp]++; } for (auto i: mp) giong[cnt] += (i.second - 1)*(i.second)/2; } if (D == 1) cout << giong[3]; else if (D == 2) cout << giong[2] - 3*giong[3]; else if (D == 3) cout << giong[1] - 2*giong[2] + 3*giong[3]; else cout << giong[0] - giong[1] + 2*giong[2] - 3*giong[3]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...