main
黄海 2 years ago
parent ea9b23f700
commit 87f7595956

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