# 9.22模拟赛解题报告

## 心路历程

T2车祸现场：

%……&*…&*（%￥……&

T1傻逼题。。。。然而期间翻了无数次车，做完就快过去1h了。。

T2读题就花了半个小时，而且一开始没认真理解题目的意思，前后各dp了一遍，后来仔细揣摩了一下题意，细心品味了一下出题人的语言，正着的dp好像是没用的。。。

## Sol

### A

#include<cstdio>
#include<algorithm>
#include<iostream>
#define int long long
using namespace std;
const int INF = 1e18 + 10;
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N, sx, sy, ex, ey;
main() {
freopen("grid.in", "r", stdin);
freopen("grid.out", "w", stdout);
cout << max(abs(ex - sx), abs(ey - sy));
return 0;
}
/*
8 2 3 7 5
5

4
1 1 2 2
1

4
1 1 2 3
2

10 2 4 3 10

10 1 1 1 1
*/

### B

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
//#define int long long
using namespace std;
const int MAXN = 1e6 + 10;
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N, T, opt, f[MAXN], g[MAXN][2];
char s[MAXN];
vector<string> ans;
map<string, bool> mp;
void get2() {
for(int i = N - 1; i >= 4; i--) {
int r = (N - (i + 1));
if(r == 1) continue;
if((opt == 0 && g[i][0]) || (opt != 0))
ans.push_back(string(s + i, s + i + 2));
}
}
void get3() {
for(int i = N - 2; i >= 4; i--) {
int r = (N - (i + 2));
if(r == 1) continue;
if((opt == 0 && g[i][1]) || (opt != 0))
ans.push_back(string(s + i, s + i + 3));
}
}
void pre() {
g[N - 1][0] = 1;//0：末尾长度为2
g[N - 2][1] = 1;//1: 末尾长度为3
for(int i = N - 3; i >= 4; i--) {

if((s[i] != s[i + 2]) || (s[i + 1] != s[i + 3])) g[i][0] = g[i + 2][0];
g[i][0] |= g[i + 2][1];

if((s[i] != s[i + 3]) || (s[i + 1] != s[i + 4]) || (s[i + 2] != s[i + 5])) g[i][1] = g[i + 3][1];
g[i][1] |= g[i + 3][0];

}
}
main() {
freopen("ling.in", "r", stdin);
freopen("ling.out", "w", stdout);
while(T--) {
ans.clear();
mp.clear();
memset(g, 0, sizeof(g));
scanf("%s", s + 1);
N = strlen(s + 1);
pre();
get2();
get3();
sort(ans.begin(), ans.end());
int num = 0;
for(int i = 0; i < ans.size(); i++) {
if(i == 0 || (ans[i] != ans[i - 1])) num++;
}
cout << num << endl;
for(int i = 0; i < ans.size(); i++) {
if(mp.find(ans[i]) == mp.end()) {
mp[ans[i]] = 1;
cout << ans[i] << endl;
}
}
}
return 0;
}
/*
2 0
abc
aaaaaa
*/

### C

https://www.cnblogs.com/zwfymqz/p/9690449.html

1811 篇文章118 人订阅

0 条评论

4099

3836

4056

3143

1243

2918

1054

1906

2803

1073