You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.1 KiB

2 years ago
#include <bits/stdc++.h>
2 years ago
const int N = 110;
char a[N][N];
/*
4
abccddadca
2 years ago
2
aaa
2 years ago
*/
2 years ago
using namespace std;
2 years ago
2 years ago
struct Node {
2 years ago
int x, y;
2 years ago
char c;
2 years ago
};
2 years ago
vector<Node> q;
2 years ago
/*
1 double
:sqrt(3)
sqrt(3) 1
*/
int pf(int x) {
return x * x;
}
bool check(Node a, Node b, Node c) {
2 years ago
if (a.c != b.c || a.c != c.c || b.c != c.c) return false;
2 years ago
// a与b之间距离 不等于 a与c之间距离
if (pf(a.x - b.x) + pf(a.y - b.y) * 3 != pf(a.x - c.x) + pf(a.y - c.y) * 3) return false;
// a与b之间距离 不等于 b与c之间距离
if (pf(a.x - b.x) + pf(a.y - b.y) * 3 != pf(b.x - c.x) + pf(b.y - c.y) * 3) return false;
return true;
}
2 years ago
int main() {
2 years ago
#ifndef ONLINE_JUDGE
freopen("ZhiMuSanJiaoXing.in", "r", stdin);
#endif
int n;
cin >> n;
string s;
cin >> s;
// 先把字符串存入char[][]
int idx = 0;
for (int i = 0; i < n; i++) // n行
for (int j = 0; j <= i; j++) // i列
a[i][j] = s[idx++];
// 把所有坐标记录下来
2 years ago
for (int i = 0; i < n; i++) {
2 years ago
for (int j = 0; j <= i; j++) {
q.push_back({n - 1 - i, j, a[i][j]});
// cout << "x=" << n - 1 - i << ",y=" << j << " " << a[i][j] << endl;
}
2 years ago
}
2 years ago
2 years ago
vector<char> res;
// 在q数组中选择任意三个计算两两间距离是不是相等
for (int i = 0; i < q.size(); i++)
2 years ago
for (int j = i + 1; j < q.size(); j++)
for (int k = j + 1; k < q.size(); k++) {
if (check(q[i], q[j], q[k])) res.push_back(q[i].c);
2 years ago
}
2 years ago
2 years ago
// if (res.size() == 0)
// cout << "No Solution" << endl;
// else {
// sort(res.begin(), res.end());
// for (char x : res) cout << x << endl;
// }
2 years ago
return 0;
}