-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperator.c
More file actions
110 lines (107 loc) · 1.77 KB
/
operator.c
File metadata and controls
110 lines (107 loc) · 1.77 KB
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
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Player {
public:
string score;
Player(string score) : score(score) {};
bool operator >(const Player& other) const {
int len = score.size();
int scores1 = 0;
int scores2 = 0;
int cosc1 = 0;
int cosc2 = 0;
int tmp = 0;
vector<int> fails1;
vector<int> fails2;
for (int i = 0; i < len; i++) {
char c = score[i];
if (c == '1') {
scores1++;
tmp++;
}
else if (c == '0') {
if (cosc1 < tmp) {
cosc1 = tmp;
}
tmp = 0;
fails1.push_back(i);
}
}
if (tmp > cosc1) {
cosc1 = tmp;
}
tmp = 0;
for (int i = 0; i < len; i++) {
char c = other.score[i];
if (c == '1') {
scores2++;
tmp++;
}
else if (c == '0') {
if (cosc2 < tmp) {
cosc2 = tmp;
}
tmp = 0;
fails2.push_back(i);
}
}
if (tmp > cosc2) {
cosc2 = tmp;
}
if (scores1 > scores2) {
return true;
}
else if (scores1 < scores2) {
return false;
}
else {
if (cosc1 > cosc2) {
return true;
}
else if (cosc1 < cosc2) {
return false;
}
else {
for (int j = 0; j < (int)fails1.size(); j++) {
if (fails1[j] > fails2[j]) {
return true;
}
else if (fails1[j] < fails2[j]) {
return false;
}
}
return false;
}
}
}
};
int main() {
int n;
int m;
cin >> n >> m;
vector<int> nums;
vector<Player> S;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
Player p(s);
S.push_back(p);
nums.push_back(i + 1);
}
for (int i = 0; i < n-1; i++) {
Player tmp = S[i + 1];
int j = i;
while (j >= 0 && tmp > S[j] ) {
swap(S[j], S[j + 1]);
swap(nums[j], nums[j + 1]);
j--;
}
}
for (int i = 0; i < n-1; i++) {
cout << nums[i] << ' ';
}
cout << nums[n - 1];
return 0;
}