# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
862187 |
2023-10-17T16:23:44 Z |
TAhmed33 |
Set (COCI21_set) |
C++ |
|
0 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
int op (string a, string b) {
int ret = 0;
for (int i = 0; i < (int)a.length(); i++) {
ret *= 3;
if (a[i] == b[i]) ret += a[i] - '0';
else if (a[i] == '1' && b[i] == '2') {
ret += 3;
} else if (a[i] == '2' && b[i] == '1') {
ret += 3;
} else if (a[i] == '1' && b[i] == '3') {
ret += 2;
} else if (a[i] += '3' && b[i] == '1') {
ret += 2;
} else {
ret++;
}
}
return ret;
}
int freq[6563];
int hsh[2188];
string arr[2188];
int hashh (string s) {
reverse(s.begin(), s.end());
int cnt = 0;
while (s.length()) {
cnt *= 3;
cnt += (s.back() - '0');
s.pop_back();
}
return cnt;
}
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> arr[i];
hsh[i] = hashh(arr[i]);
freq[hsh[i]]++;
}
long long ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i == j) continue;
ans += freq[op(arr[i], arr[j])];
if (arr[i] == arr[j]) ans -= 2;
}
}
ans /= 6;
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |