Poj 3561 pseudo graphical recognizer (Search)

Source: Internet
Author: User

// 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/>} 

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.