POJ 2585 Window pains topology Ordering

Source: Internet
Author: User

1#include <cstdio>2#include <iostream>3#include <cstring>4 #defineCL (b) memset (A,b,sizeof (a))5 using namespacestd;6 7 Const intmaxn=Ten;8 9 intT;Ten intCNT[MAXN]; One intMP[MAXN][MAXN]; A intNUM[MAXN][MAXN]; - intCOVER[MAXN][MAXN][MAXN]; - BOOLVIS[MAXN]; the BOOLLINK[MAXN][MAXN]; -  - intdx[]= {0,0,1,1}; - intdy[]= {0,1,0,1}; +  - voidInit () + { A     inti,j; atCL (cover,0); -      for(intk=0; k<9; k++) -     { -i=k/3, j=k%3; -          for(intL=0; l<4; l++) -         { in             intx=i+Dx[l]; -             inty=j+Dy[l]; tocover[x][y][num[x][y]++]=k+1; +         } -     } the } *  $ voidbuild ()Panax Notoginseng { -      for(intI=0; i<4; i++) the     { +          for(intj=0; j<4; J + +) A         { the              for(intk=0; k<num[i][j]; k++) +             { -                 if((!Link[mp[i][j]][cover[i][j][k]]) $&& (mp[i][j]!=Cover[i][j][k])) $                 { -link[mp[i][j]][cover[i][j][k]]=true; -cnt[cover[i][j][k]]++; the                 } -             }Wuyi         } the     } - } Wu  - BOOLTopsort () About { $      while(t--) -     { -  -         intnow=1; A          while(!vis[now]| | (now<=9&&cnt[now]>0)) +         { thenow++; - //printf ("%d\n", now); $         } the  the         if(now>9) the         { the             return false; -         } invis[now]=false; the          for(intI=1; i<=9; i++) the         { About             if(vis[i]&&Link[now][i]) the             { thecnt[i]--; the             } +         } -     } the     return true;Bayi } the  the intMain () - { - init (); the     CharSTR[MAXN]; the      while(SCANF ("%s", str) &&str[0]=='S') the     { theCL (CNT,0), t=0; -CL (VIS,false); theCL (link,false); the          for(intI=0; i<4; i++) the         {94              for(intj=0; j<4; J + +) the             { thescanf"%d",&mp[i][j]); the                 if(!Vis[mp[i][j]])98                 { Aboutt++; -vis[mp[i][j]]=true;101                 }102             }103         }104 build (); thescanf"%s", str);106         if(Topsort ()) puts ("these WINDOWS is clean");107         ElsePuts"These WINDOWS is broken");108     }109     return 0; the}/*111  the START113 1 2 3 3 the 4 5 6 6 the 7 8 9 9 the 7 8 9 9117 END118 START119 1 1 3 3 - 4 1 3 3121 7 7 9 9122 7 7 9 9123 END124 Endofinput the 126 */

POJ 2585 Window pains topology Ordering

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.