1.21寒假每日总结12
思路&&Code
|
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
|
/*高桥 和 青木 N 场比赛x y得分情况分别为 x1 y1 ... .. xn yn计算高桥的总得分 与 青木的总得分进行比较高桥得分 > 青木得分 输出 Takahashi == 输出Draw < 输出Aoki */<br>#include <bits/stdc++.h>#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);using namespace std; int n, res, ans;int main(){ IO; cin >> n; while (n --) { int x, y; cin >> x >> y; res += x, ans += y; } if (res > ans) { cout << "Takahashi\n"; } else if (res == ans) { cout << "Draw\n"; } else { cout << "Aoki\n"; } return 0;} |
B - Extended ABC
思路&&Code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/*由 n * A + m * B + z * C 判断是不是由这个构成的字符串 n m z可以为0(可以是空串)<br>.<br>不过只要判断后面的比前面的小就行 (小小贪心一下) */#include <bits/stdc++.h>#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);using namespace std; int main(){ IO; string s; cin >> s; bool flag = 1; int len = s.size(); for (int i = 0; i < len - 1; i++) { if (s[i] > s[i + 1]) { flag = 0; break; } } return cout << (flag ? "Yes\n" : "No\n"), 0;} |
C - Lining Up 2
思路&&Code
|
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
|
/*在一个长度为N的序列 当ai 等于 -1的时候就是排头 剩下这索引对应的值就是它的前面除了-1以外 */#include <bits/stdc++.h>#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);using namespace std; int main(){ IO; int n; cin >> n; int a[n + 1] = {0}, b[n + 1] = {0}, cnt; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] == -1) { cnt = i; } else b[a[i]] = i; } cout << cnt; for (int i = 1; i < n; i++) { cout << ' ' << b[cnt]; cnt = b[cnt]; } return cout << '\n', 0;} |

浙公网安备 33010602011771号