Created
September 24, 2016 01:47
-
-
Save morris821028/d0498e3b474094ee390fc6d29c13461b to your computer and use it in GitHub Desktop.
[debug] Judge Girl 33. Intersections Submission 73738
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main(void) | |
{ | |
int a[101][101]={0},n,i,j,k,A=0,B=0,C=0,D=0; | |
scanf("%d",&n); | |
for(i=1;i<=n;i++) | |
{ | |
for(j=1;j<=n;j++) | |
{ | |
scanf("%d",&a[i][j]); | |
} | |
} | |
for(i=1;i<=n;i++) | |
{ | |
for(j=1;j<=n;j++) | |
{ | |
k=0; | |
if(a[i][j]==1) | |
{ | |
if(i+1 <= n && a[i+1][j]==1) | |
{ | |
k++; | |
} | |
if(j+1 <= n && a[i][j+1]==1) | |
{ | |
k++; | |
} | |
if(i-1 >= 1 && a[i-1][j]==1) | |
{ | |
k++; | |
} | |
if(j-1 >= 1 && a[i][j-1]==1) | |
{ | |
k++; | |
} | |
if((k==2&&(i+1 <= n && a[i+1][j]==1)&&(i-1 >= 1 && a[i-1][j]==1))||(k==2&&(j+1 <= n && a[i][j+1]==1)&&(j-1 >= 1 && a[i][j-1]==1))) | |
{ | |
k=k-2; | |
} | |
} | |
switch(k) | |
{ | |
case 1: | |
D++; | |
break; | |
case 2: | |
C++; | |
break; | |
case 3: | |
B++; | |
break; | |
case 4: | |
A++; | |
break; | |
} | |
} | |
} | |
printf("%d\n%d\n%d\n%d\n",A,B,C,D); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment