A - Election 2
题目大意:
n张票,目前投了t给高桥,a给青木。
问剩余票随便分配,是否都是一个结局。
解决思路:考虑最好的情况即可,代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 5;


int main() {
int n, t, a;
cin >> n >> t >> a;
int temp = t + a;
if (abs(t - a) + temp <= n) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
return 0;
}

B - Vertical Writing
题目大意:
旋转数组90度,空着的要填’‘且每一行字符串不能以’‘结尾

代码如下:

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
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 5;


int main() {
int n;
cin >> n;
string q[100];
string s[100];
int len = 0;
for (int i = 0; i < n; i++) {
cin >> q[i];
len = max(len, (int)q[i].size());
}
for (int i = 0; i < len; i++) {
for (int j = n - 1; j >= 0; j--) {
if (i < q[j].size()) {
s[i] += q[j][i];
} else {
s[i] += ' ';
}
}
}
for (int i = 0; i < len; i++) {
bool vis = 0;
for (int j = s[i].size() - 1; j >= 0; j--) {
if (s[i][j] != ' ') {
vis = 1;
}
if (vis && s[i][j] == ' ') {
s[i][j] = '*';
}
}
}
for (int i = 0; i < len; i++) {
cout << s[i] << '\n';
}
return 0;
}

C - Balls and Bag Query
解决思路:
用map维护各个数字球的个数

代码如下:

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
  #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 5;


int main() {
int n;
cin >> n;
map<int, int> check;
int ans = 0;
while (n--) {
int x;
cin >> x;
if (x == 1) {
int y;
cin >> y;
check[y]++;
if (check[y] == 1) {
ans++;
}
} else if (x == 2) {
int y;
cin >> y;
check[y]--;
if (check[y] == 0) {
ans--;
}
} else {
cout << ans << endl;
}
}
return 0;
}

D - Cuboid Sum Query

解决思路:
三维前缀和维护,板子题,不贴代码了QAQ

只会4个,后面尽力补补!!!