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 1015. Test the Difference!

Help!!What's wrong with my program?
Posted by cc 28 Feb 2003 13:03
#include<stdio.h>

int n,total,note[100000][7];

void init()
{
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      note[i][0]=0;
      for(j=1;j<7;j++)
        scanf("%d",&note[i][j]);
    }
}

void right(int num)
{
  int temp;
  temp=note[num][4];
  note[num][4]=note[num][1];
  note[num][1]=note[num][6];
  note[num][6]=note[num][2];
  note[num][2]=temp;
}

void left(int num)
{
  int temp;
  temp=note[num][4];
  note[num][4]=note[num][2];
  note[num][2]=note[num][6];
  note[num][6]=note[num][1];
  note[num][1]=temp;
}

void up(int num)
{
  int temp;
  temp=note[num][4];
  note[num][4]=note[num][5];
  note[num][5]=note[num][6];
  note[num][6]=note[num][3];
  note[num][3]=temp;
}

void down(int num)
{
  int temp;
  temp=note[num][4];
  note[num][4]=note[num][3];
  note[num][3]=note[num][6];
  note[num][6]=note[num][5];
  note[num][5]=temp;
}

void change(int num)
{
  if(note[num][1]==1)right(num);
  if(note[num][2]==1)left(num);
  if(note[num][3]==1)down(num);
  if(note[num][5]==1)up(num);
  if(note[num][6]==1){right(num);right(num);}
}

int compare(int num)
{
  int i,j,k;
  for(i=0;i<num;i++)
    {
      k=1;
      for(j=1;j<7;j++)
        if(note[i][j]!=note[num][j])k=0;
      if(k){note[num][0]=note[i][0];return 0;}
    }
  total++;note[num][0]=total;
  return 0;
}

void work()
{
  int i;
  if(note[0][4]!=1)change(0);note[0][0]=1;total=1;
  for(i=1;i<n;i++)
    {
      if(note[i][4]!=1)change(i);
      compare(i);
    }
}

void out()
{
  int i,j;
  printf("%d\n",total);total++;
  for(i=1;i<total;i++)
    {
      for(j=0;j<n;j++)
        if(note[j][0]==i)printf("%d ",j+1);
      printf("\n");
    }
}

void main()
{
  init();
  work();
  out();
}
Re: Help!!What's wrong with my program?
Posted by ortemij 24 Nov 2007 19:29
cc wrote 28 February 2003 13:03
#include<stdio.h>

int n,total,note[100000][7];

void init()
{
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      note[i][0]=0;
      for(j=1;j<7;j++)
        scanf("%d",&note[i][j]);
    }
}

void right(int num)
{
  int temp;
  temp=note[num][4];
  note[num][4]=note[num][1];
  note[num][1]=note[num][6];
  note[num][6]=note[num][2];
  note[num][2]=temp;
}

void left(int num)
{
  int temp;
  temp=note[num][4];
  note[num][4]=note[num][2];
  note[num][2]=note[num][6];
  note[num][6]=note[num][1];
  note[num][1]=temp;
}

void up(int num)
{
  int temp;
  temp=note[num][4];
  note[num][4]=note[num][5];
  note[num][5]=note[num][6];
  note[num][6]=note[num][3];
  note[num][3]=temp;
}

void down(int num)
{
  int temp;
  temp=note[num][4];
  note[num][4]=note[num][3];
  note[num][3]=note[num][6];
  note[num][6]=note[num][5];
  note[num][5]=temp;
}

void change(int num)
{
  if(note[num][1]==1)right(num);
  if(note[num][2]==1)left(num);
  if(note[num][3]==1)down(num);
  if(note[num][5]==1)up(num);
  if(note[num][6]==1){right(num);right(num);}
}

int compare(int num)
{
  int i,j,k;
  for(i=0;i<num;i++)
    {
      k=1;
      for(j=1;j<7;j++)
        if(note[i][j]!=note[num][j])k=0;
      if(k){note[num][0]=note[i][0];return 0;}
    }
  total++;note[num][0]=total;
  return 0;
}

void work()
{
  int i;
  if(note[0][4]!=1)change(0);note[0][0]=1;total=1;
  for(i=1;i<n;i++)
    {
      if(note[i][4]!=1)change(i);
      compare(i);
    }
}

void out()
{
  int i,j;
  printf("%d\n",total);total++;
  for(i=1;i<total;i++)
    {
      for(j=0;j<n;j++)
        if(note[j][0]==i)printf("%d ",j+1);
      printf("\n");
    }
}

void main()
{
  init();
  work();
  out();
}

nothing