ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1378. Artificial Intelligence

Somebody knows what is wrong with my program?
Posted by Kisenko Vova 13 Feb 2006 20:21
My program have WA1,but it's give me a correct answer for a test from task.

#include <iostream.h>
#include <stdio.h>
int main(){
long h,w,j,i=0;
double k,s=0,p=0;
long ar[110][110];
char c=0;
cin >>w >>h;
while (i<w*h && c!=EOF) {
if (c=='0' || c=='1') {ar[i/w+1][i%w+1]=c-'0';i++;}
c=getchar();
}
for (i=0;i<=h;i++){ar[i][0]=0;ar[i][w+1]=0;}
for (i=0;i<=w;i++){ar[0][i]=0;ar[h+1][i]=0;}
for (i=1;i<=h;i++)
    for (j=1;j<=w;j++) {
         if (ar[i][j]==1) s++; else continue;
         if (ar[i-1][j]==0 || ar[i+1][j]==0 || ar[i][j-1]==0 || ar[i][j+1]==0) p++;
         }
p=p+3;
k=p*p/s;
if (k<13) printf("circle");
      else if (k<18) printf("square");
      else printf("triangle");

return 0;
}

Maybe I have some problem with input?
P.S
Sorry,for my bad english.