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 <iostream>
#include <cstring>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
char cards[n][k + 1];
for (int i = 0; i < n; i++) {
cin >> cards[i];
}
long long count = 0;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
bool is_set = true;
for (int p = 0; p < k; p++) {
if (cards[i][p] == cards[j][p]) {
for (int q = j + 1; q < n; q++) {
if (cards[i][p] != cards[q][p] && cards[j][p] != cards[q][p]) {
is_set = false;
break;
}
}
if (!is_set) {
break;
}
}
else {
if (cards[i][p] != '1' && cards[j][p] != '1' && cards[i][p] != cards[j][p]) {
if (cards[i][p] == '2' || cards[j][p] == '2') {
for (int q = j + 1; q < n; q++) {
if (cards[q][p] != '1' && cards[i][p] != cards[q][p] && cards[j][p] != cards[q][p]) {
is_set = false;
break;
}
}
if (!is_set) {
break;
}
}
else if (cards[i][p] == '3' || cards[j][p] == '3') {
for (int q = j + 1; q < n; q++) {
if (cards[q][p] == '3' || cards[i][p] == cards[q][p] || cards[j][p] == cards[q][p]) {
is_set = false;
break;
}
}
if (!is_set) {
break;
}
}
}
else {
is_set = false;
break;
}
}
}
if (is_set) {
count++;
}
}
}
cout << count << endl;
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... |