后来看了下,给的示例通过了
#include <iostream>
#include <vector>
using namespace std;
struct pai {
char x;
char y;
char z;
pai(char x_, char y_, char z_ ):x(x_),y(y_),z(z_) {}
};
bool same(pai a, pai b) {
if (a.x == b.x && a.y == b.y && a.z == b.z)
return 1;
else
return 0;
}
bool differ(pai a, pai b) {
if (a.x != b.x && a.y != b.y && a.z != b.z)
return 1;
else
return 0;
}
int main() {
int n;
cin >> n;
char ch1,ch2,ch3;
vector<pai> ji;
for (int i = 0; i < n; i++) {
cin >> ch1 >> ch2 >> ch3;
ji.push_back(pai(ch1, ch2, ch3));
}
int sum = 0;
for (int i = 0; i < n - 2; i++) {
for (int j =i+ 1; j < n - 1; j++) {
if (same(ji[i], ji[j])) {
for (int k = j+1; k < n; k++) {
if (same(ji[i], ji[k]))
sum++;
}
}
if (differ(ji[i], ji[j])) {
for (int k = j + 1; k < n; k++) {
if (differ(ji[i], ji[k]) && differ(ji[j], ji[k]))
sum++;
}
}
continue;
}
}
cout << sum << endl;
return 0;
}
全部评论
(0) 回帖