2919 Selection Questions

Source: Internet
Author: User

2919 Selection Questions

time limit: 1 sspace limit: 16000 KBtitle level: Golden Gold SolvingTitle Description Description

A classmate exam, in N*m's answer card wrote a,b,c,d Four kinds of answers.

He finished, and can not pay, a look at the table, from the ring bell and N long.

He began to play a game: Select a lattice x, Y, from this grid to the 4 directions to find the same options, found again.

The area of the graph to be formed. (one option occupies one unit area)

Enter a description Input Description

N M X Y

Answer Card (matrix)

Output description Output Description

Area

Sample input Sample Input

3 3 1 2

A C B

C c C

D C A

Sample output Sample Output

5

Data range and Tips Data Size & Hint

N,m<=15.

For 33% data, only a.

Category labels Tags Click here to expandSearch by irrigation method
#include <cstdio>#include<iostream>using namespacestd;#defineN 101CharMap[n][n],goal;intN,m,sum,vis[n][n];voidDfsintIintj) {    if(i<1|| j<1|| i>n| | J&GT;M)return ; if(!vis[i][j]&&map[i][j]==goal) {Vis[i][j]=1; sum++; }Else return ; DFS (i+1, J); DFS (I,j+1); DFS (i-1, J); DFS (I,j-1);}intMain () {intx, y; CIN>>n>>m>>x>>y;  for(intI=1; i<=n;i++){         for(intj=1; j<=m;j++) {cin>>Map[i][j]; }} goal=Map[x][y];    DFS (x, y); printf ("%d\n", sum); return 0;}

2919 Selection Questions

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.