[Description]: The input K and P, K represents several letters, that is, the input has several lines, P indicates that each letter has several, in the form of coordinates (x, Y ). now let's divide the same letter into a rectangle and ask if it can be implemented.
[Analysis]: Alas, low-level mistakes !!! Remember! Accumulation!
/* Date: 2014/11/04 time: 21: 38by: vidattention: coordinate creation is the key to understanding this problem and organizing ideas. In my coordinate system, the X axis points to the right, and the Y axis points to the bottom, just like the figure in the question! * // 228 K 0 Ms # include <iostream> using namespace STD; # define max (x, y) (x)> (y )? (X) :( y) # define min (x, y) (x) <(y )? (X) :( y) # define INF 000000000int lef [27], righ [27], up [27], under [27]; bool check (int n) {for (INT I = 0; I <n; I ++) {for (Int J = 0; j <n; j ++) {if (I = J) continue; If (LEF [J]> = lef [I] & lef [J] <= righ [I]) | (righ [J] <= righ [I] & righ [J]> = lef [I]) & (up [J]> = up [I] & up [J] <= under [I]) | (under [J] <= under [I] & under [J]> = up [I]) return 0 ;}} return 1 ;} int main () {int T, K, P; int X, Y; CIN> T; while (t --) {CIN> K> P; for (INT I = 0; I <K; I ++) {int LL = inf, RR = 0, uup = inf, UN = 0; For (Int J = 0; j <p; j ++) {CIN> x> Y; LL = min (LL, x), RR = max (RR, x ), uup = min (uup, Y), UN = max (UN, Y);} lef [I] = ll, righ [I] = RR, up [I] = uup, under [I] = UN;} For (INT I = 0; I <K; I ++) {for (Int J = 0; j <K; j ++) {if (I = J) continue; If (LEF [I]> lef [J] & lef [I] <righ [J]) lef [I] = lef [J]; If (righ [I] <righ [J] & righ [I]> lef [J]) righ [I] = righ [J]; If (up [I]> up [J] & up [I] <under [J]) up [I] = up [J]; If (under [I] <under [J] & under [I]> up [J]) under [I] = under [J] ;}} if (check (k) cout <"yes" <Endl; else cout <"no" <Endl;} return 0 ;}
Poj 1231 the alphabet game