human
Can you solve the below in CPP?
A: Isono, let's do that! --Sendame -

story

Nakajima "Isono ~, let's do that!"

Isono "What is that, Nakajima"

Nakajima "Look, that's that. It's hard to explain because I have to express it in letters for some reason."

Isono "No, it seems that you can put in figures and photos, right?"


Nakajima "It's true!"

Isono "So what are you going to do?"

Nakajima "Look, the guy who rhythmically clapping his hands twice and then poses for defense, accumulation, and attack."

Isono "Hmm, I don't know ..."

Nakajima "After clapping hands twice, for example, if it was defense"


Nakajima "And if it was a reservoir"


Nakajima "If it was an attack"


Nakajima "Do you know who you are?"

Isono "Oh! It's dramatically easier to understand when a photo is included!"

Nakajima "This is the progress of civilization!"

(It's been a long time since then)

Hanazawa "Iso's" "I'm" "I'm"

Two people "(cracking ... crackling ... crackling ...)"

Hanazawa "You guys are doing that while sleeping ...!?"

Hanazawa: "You've won the game right now ... Isono-kun, have you won now?"

Isono "... Mr. Hanazawa was here ... Nakajima I'll do it again ... zzz"

Nakajima "(Kokuri)"

Two people "(cracking ... crackling ...)"

Hanazawa "Already ... I'll leave that winning / losing judgment robot here ..."

Then Mr. Hanazawa left.

Please write that winning / losing judgment program.

problem

"That" is a game played by two people. According to the rhythm, the two people repeat the pose of defense, accumulation, or attack at the same time. Here, the timing at which two people pose is referred to as "times". In this game, when there is a victory or defeat in a certain time and there is no victory or defeat in the previous times, the victory or defeat is the victory or defeat of the game.

Each of the two has a parameter called "attack power", and the attack power is 0 at the start of the game.

When the attack pose is taken, it becomes as follows according to the attack power at that time.

* If you pose for an attack...

Write me a that, Nakajima"?
assistant
#Here is that, Nakajima"
.

#include <bits/stdc++.h>
using namespace std;
enum {
  ATT, DEF, SAV
};
class Player {
  public:
    int power;
    int state;
    bool powerflag;
    Player() {
      power = 0;
      powerflag = false;
    }
    void def() {
      if(powerflag) power = 0;
      powerflag = false;
      state = DEF;
    }
    void att() {
      state = ATT;
      if(powerflag) power = 0;
      powerflag = true;
    }
    void sav() {
      state = SAV;
      if(powerflag) power = 0;
      powerflag = false;
      if(power < 5) ++power;
    }
};
int isOvered(Player, Player);

int main() {
  int n;
  cin >> n;
  vector<vector<int>> commands(2);
  for(int t = 1; t >= 0; --t) {
    for(int i = 0; i < n; ++i) {
      string command;
      cin >> command;
      commands[t].push_back(
        command == "kougekida" ? ATT :
        command == "mamoru" ? DEF :
        SAV
      );
    }
  }
  Player nakajima, isono;
  for(int i = 0; i < n; ++i) {
    int t = 0;
    auto operate = [&](Player& player) {
      (
        (commands[t][i] == ATT) ? player.att() :
        (commands[t][i] == DEF) ? player.def() :
        player.sav()
      );
      ++t;
    };
    operate(nakajima);
    operate(isono);
    if(isOvered(nakajima, isono) >= 0) {
      cout << (isOvered(nakajima, isono) ? "Isono-kun" : "Nakajima-kun") << endl;
      return 0;
    }
  }
  cout << "Hikiwake-kun" << endl;
  return 0;
}

int isOvered(Player a, Player b) {
  auto def = [&](int num) {
    return (
      num == ATT ? "ATT" :
      num == DEF ? "DEF" :
      "SAV"
    );
  };
  // cout << def(a.state) << ", " << a.power << ",  " << def(b.state) << ", " << b.power << endl;
  bool t = false;
  do {
    Player me, you;
    (t ? you : me) = a;
    (t ? me : you) = b;
    // cout << "t: " << t << endl;
    if(me.state == ATT && you.state == ATT) {
      if(me.power == you.power) return -1;
      if(me.power > you.power) return t;
    } else if(me.state == ATT && me.power == 0) {
      return !t;
    } else if(me.state == ATT && you.state == DEF) {
      if(me.power == 5)...