Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
暴力模拟,把完整的玻璃往下搬,发现存在不完整就是Broken,全部办完就是CLean,(附代码)#include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; int a[4][4]; char s[15]; bool check(int c) { c--; int x=c/3,y=c%3;c++; int ma=0,oo=0; for(int i=x;i<=x+1;i++) for(int j=y;j<=y+1;j++) { if(a[i][j]==c) ma++; if(a[i][j]==0)oo++; } if(oo==4) return 0; if(oo+ma==4) { for(int i=x;i<=x+1;i++) for(int j=y;j<=y+1;j++) a[i][j]=0; return 1; } return 0; } void init() { for(int i=0;i<4;i++) for(int j=0;j<4;j++) scanf("%d",&a[i][j]); while(1) { int go=0; for(int i=1;i<=9;i++) { if(check(i)) go++; } if(go==0) break; } int ans=0; for(int i=0;i<4;i++) for(int j=0;j<4;j++)ans+=a[i][j]; printf("THESE WINDOWS ARE %s\n",ans?"BROKEN":"CLEAN"); } int main() { // freopen("in.txt","r",stdin); while(gets(s),strlen(s)<9) { init(); gets(s); gets(s); } // cout << "Hello world!" << endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator