A

1
2
3
4
5
6
7
8
9
10
11
12
signed main() {
IOS;
string a;
cin >> a;
for (int i = 0; i < a.size(); i++) {
if (a[i] != '.') {
cout << a[i];
}
}

return 0;
}

B

普普通通的三进制

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
signed main() {
IOS;
int x;
cin >> x;
int tmp = x;
int tot = 0;
int res = 0;
while (x)
{
int idx = x % 3;
while (idx--)
{
res++;
}
x /= 3;
}
cout << res << endl;
x = tmp;
while (x)
{
int idx = x % 3;
while (idx--) {
cout << tot << ' ';
}
tot++;
x /= 3;
}

return 0;
}

C

随随便便的写一写

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
signed main() {
IOS;
int len, q;
cin >> len >> q;
string s;
cin >> s;
int ans = 0;
for (int i = 0; i < s.size() - 2; i++)
{
if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
ans++;
}
}
while (q--) {
int x;
cin >> x;
char c;
cin >> c;
ll tmp = 0;
x -= 1;
for (int i = max(x - 2, 0); i <= x; i++)
{
if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
{
tmp++;
}
}
s[x] = c;
for (int i = max(x - 2, 0); i <= x; i++)
{
if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
{
tmp--;
}
}
ans -= tmp;
cout << ans << endl;
}

return 0;
}

D

单调栈的板子

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
signed main()
{
IOS;
int n;
cin >> n;
deque<int> q;
q.push_back(0);
a[0] = 1e9;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
while (!q.empty() && a[q.back()] < a[i])
{
q.pop_back();
}
b[q.back()]++, b[i]--;
// cout << q.back() << ' ' << i << endl;
q.push_back(i);
}
for (int i = 1; i <= n; i++)
{
// cout << b[i] << ' ';
b[i] += b[i - 1];
}
// cout << endl;
for (int i = 1; i <= n; i++)
{
cout << b[i] << ' ';
}

return 0;
}

E

很奇怪的并查集

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
#define MAX 200005
vector<int> G[MAX];
int fa[MAX];

int finds(int x) {
return x == fa[x] ? x : fa[x] = finds(fa[x]);
}

void merge(int x, int y) {
int nx = finds(x), ny = finds(y);
if (nx == ny) {
return;
}
vector<int> tmp;
int tot = 0;
for (int i = 0, j = 0; i < G[nx].size() || j < G[ny].size(); )
{
if (tot > 10) {
break;
}
tot++;
if (i < G[nx].size() && j < G[ny].size())
{
if (G[nx][i] > G[ny][j]) {
tmp.push_back(G[nx][i]);
i++;
} else {
tmp.push_back(G[ny][j]);
j++;
}
continue;
}
if (i < G[nx].size()) {
tmp.push_back(G[nx][i]);
i++;
} else {
tmp.push_back(G[ny][j]);
j++;
}
}
G[nx] = tmp;
fa[ny] = nx;
G[ny].clear();
}

signed main()
{
IOS;
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
fa[i] = i;
G[i].push_back(i);
}
while (m--) {
int op, x, y;
cin >> op >> x >> y;
if (op == 1) {
merge(x, y);
} else {
int nx = finds(x);
if (G[nx].size() < y) {
cout << -1 << endl;
} else {
cout << G[nx][y - 1] << endl;
}
}
}

return 0;
}

F

来回转就好了

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
const int MAXN=2e5;
int n,m,k;
pair<long long,long long>E[52];
long long dp[2*MAXN+10],tmp[52];
int main(){
cin>>n>>m>>k;m++;
E[1]=(make_pair(n,1));
for(int i=2;i<=m;i++){
cin>>E[i].first>>E[i].second;
}
dp[k]=1;
for(int i=k-1;i>=0;i--){
for(int j=1;j<=m;j++){
tmp[j]=dp[i+E[j].first];
}
for(int j=1;j<=m;j++){
// cout<<i+E[j].second-1<<' '<<i+E[j].first<<'\n';
dp[i+E[j].second-1]=(dp[i+E[j].second-1]+tmp[j])%mod;
}
// cout<<"***\n";
}
long long ans=0;
for(int i=0;i<n;i++){
ans=(ans+dp[i])%mod;
}
cout<<ans;
return 0;
}