// Simple search question <br/> // train of thought: when reading the image, open a flag to mark the one-size-fits-all symbols and coordinates of the image, and record the number of these symbols. <Br/> // If two different symbols are found, an error is returned. No one-size-fits-all characters are found, that is, all are '. 'an error is also returned. <br/> // After filtering, you can ensure that the image is segmented by a symbol, but you are not sure whether the image is right. <br/> // determine the next step: check whether the quantity is correct and the number is incorrect. <br/> # include <iostream> <br/> using namespace STD; <br/> char map [30] [30], flag; <br/> int T, Y, X, CNT, _ y, _ x; <br/> bool correct, OK; <br/> bool search (INT y, int X, char C, int CNT) <br/>{< br/> int temp = CNT-1; <br/> If (C = '//') <br/> {<br/> for (INT I = 1; I <CNT; ++ I) <br/> {<br/> If (Map [Y + I] [x + I] = '// ') <Br/> -- temp; <br/> else return false; <br/>}< br/> else if (C = '-') <br/>{< br/> for (INT I = 1; I <CNT; ++ I) <br/>{< br/> If (Map [y] [x + I] = '-') <br/> -- temp; <br/> else return false; <br/>}< br/> else if (C = '| ') <br/> {<br/> for (INT I = 1; I <CNT; ++ I) <br/>{< br/> If (Map [Y + I] [x] = '|') <br/> -- temp; <br/> else return false; <br/>}</P> <p >}< br/> else if (C = '/') <br/>{< br/> for (INT I = 1; I <CNT; ++ I) <br/>{< br/> If (Map [Y + I] [x-I] = '/') <br/> -- temp; <br/> else return false; <br/>}< br/> If (temp! = 0) <br/> return false; <br/> else return true; <br/>}</P> <p> int main () <br/>{< br/> // freopen ("in.txt", "r", stdin); <br/> CIN> T; <br/> while (t --) <br/> {<br/> memset (MAP ,'. ', sizeof (MAP); // initialization of the map boundary is very important when you are doing questions about the graph! <Br/> scanf ("% d", & Y, & X); <br/> correct = 1, CNT = 0, OK = 0; <br/> flag = '. '; <br/> for (INT I = 1; I <= y; ++ I) <br/> {<br/> for (Int J = 1; j <= x; ++ J) <br/>{< br/> CIN> map [I] [J]; <br/> If (Map [I] [J]! = '. ') <Br/> {<br/> + + CNT; <br/> If (flag = '. ') <br/>{< br/> _ y = I; <br/> _ x = J; // record coordinates <br/> flag = map [I] [J]; <br/>}< br/> If (flag! = '.' & Map [I] [J]! = Flag & map [I] [J]! = '. ') <Br/> correct = 0; <br/>}< br/> If (CNT = 0) Correct = 0; // There is no one-size-fits-all symbol, and an error is returned. <br/> // next judgment Process <br/> If (correct) Correct = search (_ y, _ x, flag, CNT ); </P> <p> // output answer Process <br/> If (correct) <br/> cout <"correct" <Endl; <br/> else <br/> cout <"Incorrect" <Endl; <br/>}</P> <p> return 0; <br/>}