AtCoder Beginner Contest 082

A

普通模拟。

B

我觉得最简单的就是排序。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// LUOGU_RID: 174550268
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
cin>>a>>b;
sort(b.begin(),b.end());
reverse(b.begin(),b.end());
sort(a.begin(),a.end());
if(b>a)
puts("Yes");
else puts("No");
}

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
// LUOGU_RID: 174550723
#include <iostream>
using namespace std;
int n, a[100001], x, ans;
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> x;
if (x > n)
ans++;
else
a[x]++;
}
for (int i = 1; i <= n; i++)
{
if (a[i] == 0)
continue;
if (a[i] < i)
ans += a[i];
else if (a[i] > i)
ans += a[i] - i;
}
cout << ans;
return 0;
}

D

直接记录每一段的F长度,用bitset做dp即可。

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
#include <bits/stdc++.h>
#define z 16005
using namespace std;
int n, X, Y, p, c, w;
string s;
bitset<z * 2> x, y;
int main()
{
x[z] = y[z] = 1;
cin >> s >> X >> Y;
s += "T";
n = s.size();
for (int i = 0; i < n; i++)
if (s[i] == 'T')
{
if (!c)
X -= i;
else if (w = i - 1 - p)
{
if (c & 1)
y = y << w | y >> w;
else
x = x << w | x >> w;
}
p = i;
c++;
}
if (x[z + X] && y[z + Y])
cout << "Yes\n";
else
cout << "No\n";
return 0;
}