###250pt EllysPairs

排序一下求最大最小即可。

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
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std ;
#define For(i , n) for(int i = 0 ; i < (n) ; ++i)
#define SZ(x) (int)((x).size())
typedef long long lint ;
const int maxint = -1u>>2 ;
const double eps = 1e-6 ;
class EllysPairs
{
public:
int getDifference(vector <int> knowledge)
{
int tmp;
vector <int> g;
g.clear();
sort(knowledge.begin(), knowledge.end());
for(int i = 0; i < SZ(knowledge) / 2; i ++) {
tmp = knowledge[i] + knowledge[SZ(knowledge) - i - 1];
g.push_back(tmp);
}
sort(g.begin(), g.end());
return int(g[SZ(g) - 1] - g[0]);
}

};

###500pt EllysFigurines

枚举行或者列的所有操作,然后再去判断列或者行的操作。

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
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std ;
#define For(i , n) for(int i = 0 ; i < (n) ; ++i)
#define SZ(x) (int)((x).size())
typedef long long lint ;
const int maxint = -1u>>2 ;
const double eps = 1e-6 ;

class EllysFigurines
{
public:

char maze[40][40];

void init(vector <string> board) {
for(int i = 0; i < SZ(board); i ++) {
for(int j = 0; j < SZ(board[0]); j ++) {
maze[i][j] = board[i][j];
}
}
}

int getMoves(vector <string> board, int R, int C) {
bool flag;
int m[40];
int ans = 40000, tans, t;
for(int i = 0; i < 1 << (SZ(board) + 1); i ++) {
tans = 0;
init(board);
t = 0;
while(t < SZ(board)) {
int tmp = 1 << t;
if((i & tmp) > 0) {
for(int j = t; j < t + R; j ++) {
for(int k = 0; k < SZ(board[0]); k ++) {
maze[j][k] = '.';
}
}
t += R;
tans ++;
}
else {
t ++;
}
}
memset(m, 0, sizeof(m));
for(int j = 0; j < SZ(board[0]); j ++) {
flag = true;
for(int k = 0; k < SZ(board); k ++) {
if(maze[k][j] == 'X') {
flag = false;
break;
}
}
if(!flag) {
m[j] = 1;
}
}
t = 0;
while(t < SZ(board[0])) {
if(m[t]) {
t += C;
tans ++;
}
else {
t ++;
}
}
ans = min(tans, ans);
}
return (ans);
}

};

###1000pt EllysReversals

每次只能逆转前偶数个元素,就说明每两个字母可以列一组,组内可以随意交换,组间可以随意交换,将每个字符串用字典序排序即可。

注意如果是字母总和如果是奇数,最后一个字母不能改变位置。

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
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std ;
#define For(i , n) for(int i = 0 ; i < (n) ; ++i)
#define SZ(x) (int)((x).size())
typedef long long lint ;
const int maxint = -1u>>2 ;
const double eps = 1e-6 ;

class EllysReversals
{
public:
int getMin(vector <string> words)
{
int ans = 0;
bool flag[60];
string tmp;
vector <string> rec[60];
memset(flag, true, sizeof(flag));
for(int i = 0; i < SZ(words); i ++) {
rec[i].clear();
for(int j = 0; j < SZ(words[i]); j += 2) {
tmp = "";
tmp += words[i][j];
if((j + 1) < SZ(words[i]))
tmp += words[i][j + 1];
sort(tmp.begin(), tmp.end());
if(SZ(tmp) == 2)
rec[i].push_back(tmp);
}
sort(rec[i].begin(), rec[i].end());
if(SZ(words[i]) % 2 != 0) {
rec[i].push_back(tmp);
}
words[i] = "";
for(int k = 0; k < SZ(rec[i]); k ++) {
words[i] += rec[i][k];
}
}
for(int i = 0; i < SZ(words); i ++) {
for(int j = i + 1; j < SZ(words); j ++) {
if(words[i] == words[j] && flag[i] && flag[j]) {
flag[i] = flag[j] = false;
ans ++;
}
}
}
ans = SZ(words) - ans * 2;
return int(ans);
}

};