読者です 読者をやめる 読者になる 読者になる

るくすの日記 ~ Out_Of_Range ~

主にプログラミング関係

AOJ 1075 High and Low Cube

[問題文]
AIZU ONLINE JUDGE

[解法]
実装


結構しんどい

const int my_start_x[6] = {7,0,7,14,21,7};
const int my_start_y[6] = {0,7,7,7,7,14};

const int oji_start_x[6] = {36,29,36,43,50,36};
const int oji_start_y[6] = {0,7,7,7,7,14};
char C[10][7][8] = {
  {"","","","","","",""},
      {
        "#######",
        "#.....#",
        "#...|.#",
        "#.....#",
        "#...|.#",
        "#..-..#",
        "#######"
    },{
        "#######",
        "#..-..#",
        "#...|.#",
        "#..-..#",
        "#.|...#",
        "#..-..#",
        "#######"
    },{
        "#######",
        "#..-..#",
        "#...|.#",
        "#..-..#",
        "#...|.#",
        "#..-..#",
        "#######"
    },{
        "#######",
        "#.....#",
        "#.|.|.#",
        "#..-..#",
        "#...|.#",
        "#.....#",
        "#######"
    },{
        "#######",
        "#..-..#",
        "#.|...#",
        "#..-..#",
        "#...|.#",
        "#..-..#",
        "#######"
    },{
        "#######",
        "#..-..#",
        "#.|...#",
        "#..-..#",
        "#.|.|.#",
        "#..-..#",
        "#######"
    },{
        "#######",
        "#..-..#",
        "#...|.#",
        "#.....#",
        "#...|.#",
        "#.....#",
        "#######"
    },{
        "#######",
        "#..-..#",
        "#.|.|.#",
        "#..-..#",
        "#.|.|.#",
        "#..-..#",
        "#######"
    },{
        "#######",
        "#..-..#",
        "#.|.|.#",
        "#..-..#",
        "#...|.#",
        "#..-..#",
        "#######"
    }
};
void Print(char c[7][8]){
  rep(y,7){
    rep(x,7){
      cout<<c[y][x];
    }
    cout<<endl;
  }
}

int Cube(char c[7][8]){
  rep(i,10){
    bool ok = true;
    rep(y,7){
      rep(x,7){	
	if(C[i][y][x] != c[y][x]){
	  ok = false;
	  goto end;
	}
      }
    }
    if(ok) return i;
  end:;
  }
  return 0;
}
void LRRev(char c[7][8]){
  char ret[7][8];
  memset(ret,0,sizeof(ret));
  rep(y,7)
    rep(x,7)
      ret[y][6 - x] = c[y][x];
  rep(y,7)
    rep(x,7)
      c[y][x] = ret[y][x];

}
void UDRev(char c[7][8]){
  char ret[7][8];
  memset(ret,0,sizeof(ret));
  rep(y,7)
    rep(x,7)
      ret[6 - y][x] = c[y][x];
  rep(y,7)
    rep(x,7)
      c[y][x] = ret[y][x];

}
void Rotate90(char c[7][8]){
  char ret[7][8];
  memset(ret,0,sizeof(ret));
  rep(y,7){
    rep(x,7){
      if(c[y][x] == '|') ret[x][6 - y] = '-';
      else if(c[y][x] == '-') ret[x][6 - y] = '|';
      else ret[x][6 - y] = c[y][x];
    }
  }
  rep(y,7)
    rep(x,7)
      c[y][x] = ret[y][x];
}
void Rotate270(char c[7][8]){
  Rotate90(c);
  Rotate90(c);
  Rotate90(c);
}

void Change(int i,char c[7][8]){
  if(i == 0) LRRev(c);
  else if(i == 1) Rotate90(c),LRRev(c);
  else if(i == 2) LRRev(c);
  else if(i == 3) Rotate270(c),LRRev(c);
  else if(i == 4) LRRev(c);
  else if(i == 5) LRRev(c),UDRev(c);  
}
int main(){
  char grid[21][57];
  while(true){
    memset(grid,0,sizeof(grid));
    int my_c[6] = {0};
    int oji_c[6] = {0};
    rep(y,21){
      rep(x,57){
      cin>>grid[y][x];
      if(grid[0][0] == '0') return 0;
      }
    }
    char my[6][7][8];
    char oji[6][7][8];
    rep(i,6){
      for(int y = 0; y < 7; y++){
	for(int x = 0; x < 7; x++){
	  my[i][y][x] = grid[my_start_y[i] + y][my_start_x[i] + x];
	}
      }
      for(int y = 0; y < 7; y++){
	for(int x = 0; x < 7; x++){
	  oji[i][y][x] = grid[oji_start_y[i] + y][oji_start_x[i] + x];
	}
      }
    }
    rep(i,6){
      Change(i,my[i]);
      Change(i,oji[i]);
      
      my_c[i] = Cube(my[i]);
      oji_c[i] = Cube(oji[i]);
    }
    int high = 0, low = 0;
    rep(i,6){
      rep(j,6){
	if(my_c[i] > oji_c[j]) high++;
	else if(my_c[i] < oji_c[j]) low++;
      }
    }
    cout<<(high >= low ? "HIGH":"LOW")<<endl;
  }
}