|
|
|
@ -1,20 +1,16 @@
|
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
using std::sort;
|
|
|
|
|
using std::cin;
|
|
|
|
|
using std::cout;
|
|
|
|
|
using std::endl;
|
|
|
|
|
using std::string;
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
int n, flag, axis;
|
|
|
|
|
string inStr, ans;
|
|
|
|
|
struct point {
|
|
|
|
|
string s, ans;
|
|
|
|
|
struct Node {
|
|
|
|
|
int x, y;
|
|
|
|
|
char v; // value
|
|
|
|
|
};
|
|
|
|
|
std::vector<point> pt;
|
|
|
|
|
struct point inf;
|
|
|
|
|
vector<Node> pt;
|
|
|
|
|
struct Node inf;
|
|
|
|
|
|
|
|
|
|
bool comp(const point &a, const point &b) {
|
|
|
|
|
bool comp(const Node &a, const Node &b) {
|
|
|
|
|
if (a.v == b.v) {
|
|
|
|
|
return (a.x == b.x) ? (a.y < b.y) : (a.x < b.x);
|
|
|
|
|
} else {
|
|
|
|
@ -22,32 +18,25 @@ bool comp(const point &a, const point &b) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int main() {
|
|
|
|
|
cin >> n >> inStr;
|
|
|
|
|
flag = 0, axis = 0;
|
|
|
|
|
for (register int count = 0; count < n; ++count) {
|
|
|
|
|
for (register int countB = 0; countB < count + 1; ++countB) {
|
|
|
|
|
point newPt;
|
|
|
|
|
newPt.v = inStr[flag];
|
|
|
|
|
newPt.y = count;
|
|
|
|
|
newPt.x = axis + (countB << 1);
|
|
|
|
|
cin >> n >> s;
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j <= i; j++) {
|
|
|
|
|
Node newPt;
|
|
|
|
|
newPt.v = s[flag];
|
|
|
|
|
newPt.y = i;
|
|
|
|
|
newPt.x = axis + (j << 1);
|
|
|
|
|
++flag;
|
|
|
|
|
pt.push_back(newPt);
|
|
|
|
|
// used for debug
|
|
|
|
|
// cout<<newPt.v<<' '<<newPt.x<<' '<<newPt.y<<endl;
|
|
|
|
|
// end debug
|
|
|
|
|
}
|
|
|
|
|
--axis;
|
|
|
|
|
}
|
|
|
|
|
inf.x = (1 << 8), inf.y = (1 << 8), inf.v = '~';
|
|
|
|
|
pt.push_back(inf);
|
|
|
|
|
sort(pt.begin(), pt.end(), comp);
|
|
|
|
|
for (register int count = 0; count <= flag; ++count) {
|
|
|
|
|
for (int count = 0; count <= flag; ++count) {
|
|
|
|
|
if (pt[count].v == '~') {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// used for debug
|
|
|
|
|
// cout<<'*'<<pt[count].v<<' '<<pt[count-1].v<<' '<<pt[count-2].v<<endl;
|
|
|
|
|
// end debug
|
|
|
|
|
if (pt[count].v != pt[count + 1].v) {
|
|
|
|
|
if (pt[count - 2].v == pt[count].v) {
|
|
|
|
|
int dist[3];
|
|
|
|
@ -57,19 +46,15 @@ int main() {
|
|
|
|
|
+ 3 * (pt[count - 2].y - pt[count].y) * (pt[count - 2].y - pt[count].y);
|
|
|
|
|
dist[2] = (pt[count - 1].x - pt[count].x) * (pt[count - 1].x - pt[count].x)
|
|
|
|
|
+ 3 * (pt[count - 1].y - pt[count].y) * (pt[count - 1].y - pt[count].y);
|
|
|
|
|
// used for debug
|
|
|
|
|
// cout<<'*'<<pt[count].v<<' '<<dist[0]<<' '<<dist[1]<<' '<<dist[2]<<endl;
|
|
|
|
|
// end debug
|
|
|
|
|
if (dist[1] == dist[2] && dist[0] == dist[1]) {
|
|
|
|
|
ans = ans + pt[count].v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ans != "") {
|
|
|
|
|
if (ans != "")
|
|
|
|
|
cout << ans << endl;
|
|
|
|
|
} else {
|
|
|
|
|
else
|
|
|
|
|
puts("No Solution");
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|