-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMatrixGame.cpp
66 lines (60 loc) · 1.78 KB
/
MatrixGame.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
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<deque>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<sstream>
#include<cstring>
using namespace std;
class MatrixGame {
public:
vector <string> getMinimal(vector <string> m) {
int count[10];
int mrow = -1;
int mcount = 20;
for (int i = 0; i < m.size(); ++i) {
count[i] = 0;
for (int j = 0; j < m[i].size(); ++j) {
count[i] += m[i][j] == '1';
}
if (count[i] < mcount) {
mrow = i;
mcount = count[i];
}
}
string tmp = m[mrow];
m[mrow] = m[0];
m[0] = tmp;
for (int i = 0; i < m.size(); ++i) {
for (int j = 0; j < m[i].size(); ++j) {
if (m[i][j] == '0') {
for (int k = 0; k < j; ++k) {
if (m[i][k] == '1') {
int possible = true;
for (int l = 0; l < i; ++l) {
}
if (possible) {
for (int l = 0; l < m.size(); ++l) {
char c = m[i][k];
m[i][k] = m[i][j];
m[i][j] = c;
}
}
}
}
}
}
}
return m;
}
};