Question: The h * w graph is displayed. The uppercase order of the letter boxes is from the bottom to the top. Multiple sequences are output in the lexicographically ascending order. I didn't think of the idea at the beginning. Later I found that only the diagram + Topology Sorting can be used .. The figure shows that if there are other letters on the boundary of a letter box, edge [] [] is marked as 1, and the letter's entry degree is in + 1, the other letters mentioned above determine the inbound level, mark it as 0, and perform topological sorting. That is, first find a point with an inbound level of 0 and delete it, then, the vertex that is connected to the vertex with edges goes to 1 to continue searching .. [Cpp] # include <iostream> # include <cstdio> # include <string. h >#include <cstdlib> # include <algorithm> using namespace std; const int maxn = 50; char map [maxn] [maxn]; char str [maxn]; int edge [maxn] [maxn]; int in [maxn]; bool vis [maxn]; int w, h, num; int index; struct lef_top {int x, y ;} lt [maxn]; struct rig_bot {int x, y;} rb [maxn]; struct String {char s [maxn];} ans [1000]; int cmp (String, string B) {return Strcmp (. s, B. s) <0;} void get_bound () {memset (lt, 0x3f, sizeof (lt); memset (rb,-1, sizeof (rb )); // memset (flag, false, sizeof (flag); for (int I = 0; I