Language: C++

/**
 * ???????????? IV

Dice I ??¨????§????????????§?????\??????????????°????????? n
???????????????????????????????????????????????????????????????????????¨?????°???????????????????????????????????????????????°??????????????????????????????????????????????????????????????????
Dice III ??????????????¨????????????

Input
????????????????????????????????° n ?????????????????????????¶???? n
??????????????????????????¢?????°???????????????????????????

????????????????????????????????¢?????°???????????????????????????????????????????????§??????????????????????????????

Output
??\??????????????????????????????????????°????????´??? "Yes"??????????????????????????\?????????????????´??? "No"
??¨????????????????????????????????????

Constraints
2???n???100
0??? ??\?????????????????????????????¢?????°??? ???100

Sample Input 1
3
1 2 3 4 5 6
6 2 4 3 5 1
6 5 4 3 2 1

Sample Output 1
No

Sample Input 2
3
1 2 3 4 5 6
6 5 4 3 2 1
5 4 3 2 1 6

Sample Output 2
Yes
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>

class Dice {
private:
  std::map<std::string, unsigned short> DiceState;
  std::string InitialState;

public:
  Dice() : Dice("1 2 3 4 5 6") {}

  explicit Dice(std::string Param) { setDiceLabels(Param); }

  unsigned short getTop();
  unsigned short getLabel(std::string);
  unsigned short getRight(unsigned short, unsigned short);
  void roll(std::string);
  void rotate(std::string);
  void rollToTop(unsigned short Label);
  void rollToFront(unsigned short Label);
  void setDiceLabels(std::string);
  std::string findPosition(unsigned short);
  std::string getDiceLabels();
  std::string getInitialState();
};

unsigned short Dice::getTop() { return DiceState["Top"]; }
unsigned short Dice::getLabel(std::string SurfaceName) {
  return DiceState[SurfaceName];
}

void Dice::roll(std::string Direction) {
  unsigned short Tmp;
  for (const auto &e : Direction) {
    if (e == 'N') {
      Tmp = DiceState["Rear"];
      DiceState["Rear"] = DiceState["Top"];
      DiceState["Top"] = DiceState["Front"];
      DiceState["Front"] = DiceState["Bottom"];
      DiceState["Bottom"] = Tmp;
    } else if (e == 'E') {
      Tmp = DiceState["Right"];
      DiceState["Right"] = DiceState["Top"];
      DiceState["Top"] = DiceState["Left"];
      DiceState["Left"] = DiceState["Bottom"];
      DiceState["Bottom"] = Tmp;
    } else if (e == 'W') {
      Tmp = DiceState["Left"];
      DiceState["Left"] = DiceState["Top"];
      DiceState["Top"] = DiceState["Right"];
      DiceState["Right"] = DiceState["Bottom"];
      DiceState["Bottom"] = Tmp;
    } else if (e == 'S') {
      Tmp = DiceState["Front"];
      DiceState["Front"] = DiceState["Top"];
      DiceState["Top"] = DiceState["Rear"];
      DiceState["Rear"] = DiceState["Bottom"];
      DiceState["Bottom"] = Tmp;
    }
  }
}

void Dice::rotate(std::string Direction) {
  unsigned short Tmp;
  for (const auto &e : Direction) {
    if (e == 'R') {
      Tmp = DiceState["Rear"];
      DiceState["Rear"] = DiceState["Left"];
      DiceState["Left"] = DiceState["Front"];
      DiceState["Front"] = DiceState["Right"];
      DiceState["Right"] = Tmp;
    } else if (e == 'L') {
      Tmp = DiceState["Rear"];
      DiceState["Rear"] = DiceState["Right"];
      DiceState["Right"] = DiceState["Front"];
      DiceState["Front"] = DiceState["Left"];
      DiceState["Left"] = Tmp;
    }
  }
}

void Dice::rollToTop(unsigned short Label) {
  std::string StartPosition = findPosition(Label);
  if (StartPosition == "Front") {
    roll("N");
  } else if (StartPosition == "Right") {
    roll("W");
  } else if (StartPosition == "Left") {
    roll("E");
  } else if (StartPosition == "Rear") {
    roll("S");
  } else if (StartPosition == "Bottom") {
    roll("EE");
  }
}

void Dice::rollToFront(unsigned short Label) {
  std::string StartPosition = findPosition(Label);
  if (StartPosition == "Right") {
    roll("WSE");
  } else if (StartPosition == "Left") {
    roll("ESW");
  } else if (StartPosition == "Rear") {
    roll("SSEE");
  } else if (StartPosition == "Top") {
    roll("S");
  } else if (StartPosition == "Bottom") {
    roll("N");
  }
}

void Dice::setDiceLabels(std::string Str) {
  InitialState = Str;
  std::istringstream iss(Str);
  unsigned short n;
  size_t i = 0;

  while (iss >> n) {
    size_t j = i;
    i++;
    switch (j) {
    case 0:
      DiceState["Top"] = n;
      break;
    case 1:
      DiceState["Front"] = n;
      break;
    case 2:
      DiceState["Right"] = n;
      break;
    case 3:
      DiceState["Left"] = n;
      break;
    case 4:
      DiceState["Rear"] = n;
      break;
    case 5:
      DiceState["Bottom"] = n;
      break;
    default:
      break;
    }
  }
}

unsigned short Dice::getRight(unsigned short Top, unsigned short Front) {
  rollToTop(Top);
  rollToFront(Front);
  return getLabel("Right");
}

std::string Dice::findPosition(unsigned short Label) {
  auto its =
      find_if(DiceState.begin(), DiceState.end(),
              [Label](std::map<std::string, unsigned short>::value_type &p) {
                return p.second == Label;
              });
  return its->first;
}

std::string Dice::getDiceLabels() {
  std::ostringstream oss;

  oss << DiceState["Top"] << " ";
  oss << DiceState["Front"] << " ";
  oss << DiceState["Right"] << " ";
  oss << DiceState["Left"] << " ";
  oss << DiceState["Rear"] << " ";
  oss << DiceState["Bottom"];

  return oss.str();
}

std::string Dice::getInitialState() {
  return InitialState;
}

int main(int argc, char const *argv[]) {
  std::string D1Labels, D2Labels, Param;
  std::istringstream iss;
  unsigned short n;

  getline(std::cin, Param);
  iss.str(Param);
  iss >> n;
  iss.clear();

  getline(std::cin, D1Labels);
  // Top,Front,Right,Left,Rear,Bottom;
  Dice* D1;
  D1 = new Dice(D1Labels);
  unsigned short TrueCount = 0;
  // Dice D2;
  Dice* D2;

  for (size_t i = 0; i < n - 1; i++) {
    getline(std::cin, D2Labels);
    D2 = new Dice;

    D2->setDiceLabels(D2Labels);

    // D2->rollToTop(D1->getTop());
    // // std::cout << D2.getDiceLabels() << std::endl;
    // D2->rollToFront(D1->getLabel("Front"));
    // if (D1Labels == D2->getDiceLabels()) {
    //   TrueCount++;
    // } else {
      for (const auto& e : D2Labels) {
        D2->rollToTop(e);
        for (size_t i = 0; i < 4; i++) {
          D2->rotate("R");
          std::string D2tmp = D2->getDiceLabels();
          if (D1Labels == D2tmp) {
            TrueCount++;
            break;
          }
        }
    //   }
    // }
    delete D2;
  }
  if (TrueCount == 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  delete D1;

  return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:273:2: error: expected '}' at end of input
  273 | }
      |  ^
a.cc:221:40: note: to match this '{'
  221 | int main(int argc, char const *argv[]) {
      |                                        ^