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.

94 lines
2.7 KiB

2 years ago
#include <bits/stdc++.h>
2 years ago
const int N = 110;
char a[N][N];
2 years ago
2 years ago
using namespace std;
2 years ago
const double eps = 1e-8;
int n;
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
/*
4
abccddadca
2
aaa
*/
2 years ago
/*
1 double
:sqrt(3)
sqrt(3) 1
2 years ago
n=4
3,3*sqrt(3)
:2,2*sqrt(3) : 2+2,2*sqrt(3)
:1,1*sqrt(3) : 1+2,1*sqrt(3) :1+2+2,1*sqrt(3)
:0,0 :0+2,0 :0+2+2,0 :0+2+2+2,0
ij
i1n=4
j1i
x=n-i + (j-1)*2
y=(n-i)*sqrt(3)
2 years ago
*/
bool check(Node a, Node b, Node c) {
2 years ago
// n - i + (j - 1) * 2, (n - i) * sqrt(3)
2 years ago
if (a.c != b.c || a.c != c.c || b.c != c.c) return false;
2 years ago
2 years ago
double ax = (n - a.x + (a.y - 1) * 2);
double bx = (n - b.x + (b.y - 1) * 2);
double cx = (n - c.x + (c.y - 1) * 2);
double ay = (n - a.x) * sqrt(3);
double by = (n - b.x) * sqrt(3);
double cy = (n - c.x) * sqrt(3);
double c1 = (ax - bx) * (ax - bx) + (ay - by) * (ay - by);
double c2 = (ax - cx) * (ax - cx) + (ay - cy) * (ay - cy);
double c3 = (bx - cx) * (bx - cx) + (by - cy) * (by - cy);
if (abs(c1 - c2) < eps && abs(c1 - c3) < eps && abs(c2 - c3) < eps) return true;
return false;
2 years ago
}
2 years ago
int main() {
2 years ago
#ifndef ONLINE_JUDGE
2 years ago
freopen("51nod_1909_2_in.txt", "r", stdin);
2 years ago
#endif
2 years ago
2 years ago
cin >> n;
string s;
cin >> s;
// 先把字符串存入char[][]
int idx = 0;
2 years ago
for (int i = 1; i <= n; i++) // n行
for (int j = 1; j <= i; j++) // i列
2 years ago
a[i][j] = s[idx++];
2 years ago
// 把所有序号记录下来
for (int i = 1; i <= n; i++)
for (int j = 1; j <= i; j++)
q.push_back({i, j, a[i][j]});
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++)
2 years ago
for (int k = j + 1; k < q.size(); k++)
2 years ago
if (check(q[i], q[j], q[k])) res.push_back(q[i].c);
2 years ago
if (res.size() == 0)
cout << "No Solution" << endl;
else {
sort(res.begin(), res.end());
2 years ago
for (char x : res) cout << x;
2 years ago
}
2 years ago
return 0;
}