parent
f13e2c522f
commit
5db2203817
@ -0,0 +1,49 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 110;
|
||||
char a[N][N];
|
||||
const double eps = 1e-8;
|
||||
int n;
|
||||
struct Node {
|
||||
int x, y;
|
||||
char c;
|
||||
};
|
||||
vector<Node> q;
|
||||
bool check(Node a, Node b, Node c) {
|
||||
if (a.c != b.c || a.c != c.c || b.c != c.c) return false;
|
||||
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;
|
||||
}
|
||||
int main() {
|
||||
cin >> n;
|
||||
string s;
|
||||
cin >> s;
|
||||
int idx = 0;
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = 1; j <= i; j++)
|
||||
a[i][j] = s[idx++];
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = 1; j <= i; j++)
|
||||
q.push_back({i, j, a[i][j]});
|
||||
vector<char> res;
|
||||
for (int i = 0; i < q.size(); i++)
|
||||
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);
|
||||
if (res.size() == 0)
|
||||
cout << "No Solution" << endl;
|
||||
else{
|
||||
sort(res.begin(), res.end());
|
||||
for (char x : res) cout << x;
|
||||
}
|
||||
return 0;
|
||||
}
|
Binary file not shown.
Loading…
Reference in new issue