@GatorGirl/

UnpleasantExcitingAttributes

C++11

No description

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
https://open.kattis.com/problems/flipfive
*/

#include <iostream>
#include <vector>
#include <string>
using namespace std;

/*

*.*
..*
*.*
1

*/

class Board
{
  public:
    bool topLeft;
    bool topMiddle;
    bool topRight;
    bool middleLeft;
    bool middleMiddle;
    bool middleRight;
    bool bottomLeft;
    bool bottomMiddle;
    bool bottomRight;
};

bool determineColor(string symbol)
{
  cout << symbol << "~";
  if (symbol == "*")
  {
    cout << false << endl;
    return false;
  }
  else if (symbol == ".")
  {
    cout << false << endl;
    return true;
  }
  return false;
}

int countMoves(Board* curr)
{
  cout << curr->topLeft << curr->topMiddle << curr->topRight << curr->middleLeft << curr->middleMiddle << curr->middleRight << curr->bottomLeft << curr->bottomMiddle << curr->bottomRight << endl;

  int count = 0;
  if (!curr->middleMiddle)
  {
    curr->topMiddle = true;
    curr->bottomMiddle = true;
    curr->middleLeft = true;
    curr->middleRight = true;
    count ++;
    cout << "used middle" << endl;
  }
  if (!curr->topMiddle)
  {
    curr->topLeft= true;
    curr->topRight = true;
    curr->middleMiddle = true;
    count ++;
  }
  if (!curr->bottomMiddle)
  {
    curr->bottomLeft= true;
    curr->bottomRight = true;
    curr->middleMiddle = true;
    count ++;
  }
  if (!curr->middleLeft)
  {
    curr->topLeft= true;
    curr->bottomLeft = true;
    curr->middleMiddle = true;
    count ++;
  }
  if (!curr->middleRight)
  {
    curr->topRight= true;
    curr->bottomRight = true;
    curr->middleMiddle = true;
    count ++;
  }
  if (!curr->topLeft)
  {
    curr->topMiddle = true;
    curr->middleLeft = true;
    count ++;
  }
  if (!curr->bottomRight)
  {
    curr->bottomMiddle = true;
    curr->middleRight = true;
    count ++;
  }
  if (!curr->topRight)
  {
    curr->topMiddle = true;
    curr->middleRight = true;
    count ++;
  }
  if (!curr->bottomLeft)
  {
    curr->bottomMiddle = true;
    curr->middleLeft = true;
    count ++;
  }
  return count;
}

int main() 
{
  /*
  2
*..
**.
*..
***
*..
..*
  */
  vector<Board*> boards;
  int numBoards;
  string line;
  cin >> numBoards;
  for (int i = 0; i < numBoards; i ++)
  {
    Board *curr = new Board();
    for (int j = 1; j <= 3; j ++)
    {
      cin >> line;
      if (j == 1)
      {
        curr->topLeft = determineColor(line.substr(0, 1));
        curr->topMiddle = determineColor(line.substr(1, 2));
        curr->topRight = determineColor(line.substr(2, 3));
      }
      if (j == 2)
      {
        curr->middleLeft = determineColor(line.substr(0, 1));
        curr->middleMiddle = determineColor(line.substr(1, 2));
        curr->middleRight = determineColor(line.substr(2, 3));
      }
      if (j == 3)
      {
        curr->bottomLeft = determineColor(line.substr(0, 1));
        curr->bottomMiddle = determineColor(line.substr(1, 2));
        curr->bottomRight = determineColor(line.substr(2, 3));
      }
    }
    boards.push_back(curr);
  }

  for (int i = 0; i < numBoards; i ++)
  {
    Board* thing = boards[i];
    cout << countMoves(thing) << endl;
  }
}