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 1125. Hopscotch

Where is my error ? I got WA . Can you help me ! Pls
Posted by Ursachi Ionut 30 Mar 2002 18:26
Here is my source :

#include <stdio.h>

int n,m;
long y[60][60];
char in[60][60],x[60][60],sel[3000];

void read_data()
 {
  int i,j;
  FILE *f=stdin;
  fscanf(f,"%d%d",&m,&n);
  fscanf(f,"%c",&in[0][0]);
  for(i=0;i<m;i++)
   fgets(in[i],100,f);
  for(i=0;i<m;i++)
   for(j=0;j<n;j++)
    fscanf(f,"%ld",&y[i][j]);
 }

void init()
 {
  int i;
  for(i=0;i<=50;i++)
   sel[i*i]=1; //sel[i]== 1 if i==(X*X)
               //         0 else
 }

void expand(int a,int b,int nr)
 {
  int i,j;
  for(i=0;i<m;i++)
   for(j=0;j<n;j++)
    if(j==b || i==a || sel[((i-a)*(i-a)+(j-b)*(j-b))])
     x[i][j]=x[i][j] ^ nr;
 }

void solve()
 {
  int i,j;
  init();
  for(i=0;i<m;i++)
   for(j=0;j<n;j++)
    if(y[i][j])expand(i,j,y[i][j]%2);
 }

void print()
 {
  int i,j;
  FILE *f=stdout;
  for(i=0;i<m;i++)
   {
    for(j=0;j<n;j++)
     if(x[i][j])
      if(in[i][j]=='B')fprintf(f,"W");
      else fprintf(f,"B");
     else fprintf(f,"%c",in[i][j]);
    fprintf(f,"\n");
   }
 }

void main()
 {
  read_data();
  solve();
  print();
 }
Simple (+)
Posted by Andrey Popyk (popyk@ief.tup.km.ua) 30 Mar 2002 19:59
if in expand (i-a)=50 and (j-b)=50 then (i-a)*(i-a)+(j-b)*(j-b)=5000

Just change sel[3000] // need more!

and

void init()
 {
  int i;
  for(i=0;i<=50;i++) // not 50!!! need more!!!
   sel[i*i]=1; //sel[i]== 1 if i==(X*X)
               //         0 else
 }
Thank you ! I got AC .
Posted by Ursachi Ionut 31 Mar 2002 00:35
Re: Simple (+)
Posted by MAK 19 Sep 2009 02:20
Thank you a lot!