UVA 705 Slash Maze Slash Maze

Source: Internet
Author: User

Alas, the morning has not been in the state, have not thought, basically is to look at the problem, remember to do the topic must be focused, must think more, can not easily see the problem, this question can be '/' and ' \ ' transformation, with 0 and 1,

'/' is represented as: ' \ ' as

001100

010010

001

It's three times times bigger, and the final result divided by three is OK.

Then you can use the ordinary search, or connectivity problems, note that as long as it is traversed around the edge of the 0 to show that this must not ring, WA once, or did not notice that each group of cases have a blank line;

On the code: (basically the same as others write)

#include <stdio.h> #include <stdlib.h> #include <string.h>int map[300][300];char a[100];int dx[4]={- 1,0,0,1};int dy[4]={0,-1,1,0};int w,h,flag,sum,ans;void dfs (int x,int y) {map[x][y] = 1;for (int i=0; i<4; i++) {int xx = X+dx[i];int yy = y+dy[i];if (xx>=0&&yy>=0&&xx<3*h&&yy<3*w) {if (map[xx][yy]==0) { sum++;d FS (XX,YY);}} Else{flag = 0;}}} int main () {int I,j;int num = 0;while (scanf ("%d%d", &w,&h), w+h) {Num++;getchar (); memset (map,0,sizeof (map)); for (i=0; i

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

UVA 705 Slash Maze Slash Maze

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.