This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 50000;
const int MAX_M = 6;
int N, M;
int main() {
cin >> N >> M;
int c = 0;
char words[MAX_N][MAX_M];
for (int i = 0; i < N; ++i) { // Read input O(NM)
for (int j = 0; j < M; ++j) {
cin >> words[i][j];
}
}
// For every pair (a, b) - O(N^2 * M)
for (int i = 0; i < N; ++i) {
for (int j = i + 1; j < N; ++j) {
int valid = 1;
for (int k = 0; k < M; ++k) {
if (words[i][k] == '?' || words[j][k] == '?')
continue;
if (words[i][k] != words[j][k])
{
valid = 0;
break;
}
}
c += valid;
}
}
cout << c;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |