Poj 1128 Frame Stacking

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.