题解
2023-09-01 16:44:07
发布于:广东
1阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
const int WIDTH = 3;
vector<string> board(WIDTH);
set<set<char>> winners[WIDTH + 1];
void insert(vector<pair<int, int>> coordinates) {
set<char> contained;
for (const pair<int, int> &p : coordinates) {
contained.insert(board[p.first][p.second]);
}
winners[contained.size()].insert(contained);
}
int main() {
for (int r = 0; r < WIDTH; r++) { cin >> board[r]; }
for (int i = 0; i < WIDTH; i++) { insert({{i, 0}, {i, 1}, {i, 2}}); }
for (int i = 0; i < WIDTH; i++) { insert({{0, i}, {1, i}, {2, i}}); }
insert({{0, 0}, {1, 1}, {2, 2}});
insert({{2, 0}, {1, 1}, {0, 2}});
cout << winners[1].size() << endl;
cout << winners[2].size() << endl;
}
这里空空如也
有帮助,赞一个