2023 RoboCom 世界机器人开发者大赛-本科组(省赛) CAIP 完整版题解
题目之后出来再补
1
//
// Created by trudbot on 2023/7/15.
//
#include <bits/stdc++.h>
using namespace std;int main () {int n; cin >> n;vector<vector<int>> ans(2, vector<int>(4, 0));while (n --) {int c, p; cin >> c >> p;ans[c][p] ++;}auto t = ans;for (auto &v : ans) {for (int i = 1; i <= 3; i ++) {cout << v[i];if (i != 3) cout << " ";}cout << endl;}sort(ans.begin(), ans.end());if (t == ans) cout << "The second win!";else cout << "The first win!";return 0;
}
2
//
// Created by trudbot on 2023/7/15.
//
#include <bits/stdc++.h>
using namespace std;int main () {int n, m; cin >> n >> m;map<string, string> h;for (int i = 0; i < n; i ++) {string s, lev; cin >> s >> lev;h[s] = lev;}for (int i = 0; i < m; i ++) {string s; cin >> s;if (h.count(s)) cout << h[s] << endl;else {int cnt = 0;string lev;for (auto &p : h) {if (s.size() > p.first.size() && s.substr(0, p.first.size()) == p.first && h.count(s.substr(p.first.size()))) {cnt ++, lev = h[p.first] + h[s.substr(p.first.size())];}}if (cnt == 1) cout << lev << endl;else cout << "D\n";}}return 0;
}
3
4
//
// Created by trudbot on 2023/7/15.
//
#include "bits/stdc++.h"
using namespace std;
vector<pair<int, int>> g[2010][2];
vector<string> name(2010);
bool st[2000][2];
int idx = 0;vector<pair<int, int>> bfs(int x, int d) {queue<pair<int, int>> q;memset(st, false, sizeof st);vector<vector<pair<int, int>>> last(idx + 1, vector<pair<int, int>>(2, {0, 0}));vector<vector<int>> dist(idx + 1, vector<int>(2, 1e9));q.push({x, d}), st[x][d] = true, dist[x][d] = 1;while (!q.empty()) {auto p = q.front(); q.pop();if (p.first == x && p.second == 1 - d) break;for (auto &e : g[p.first][p.second]) {if (!st[e.first][e.second]) {st[e.first][e.second] = true;last[e.first][e.second] = p;dist[e.first][e.second] = dist[p.first][p.second] + 1;q.push(e);}}}if (st[x][1 - d]) {vector<pair<int, int>> res;pair<int, int> t{x, 1 - d};do {res.push_back(t);t = last[t.first][t.second];} while (t.first != 0);return res;}return {};
}int main () {unordered_map<string, int> id;int n; cin >> n;for (int i = 1; i <= n; i ++) {string sa, sb;int da, db;cin >> sa >> da >> sb >> db;if (!id.count(sa)) {id[sa] = ++ idx;name[idx] = sa;}if (!id.count(sb)) {id[sb] = ++ idx;name[idx] = sb;}g[id[sa]][da].emplace_back(id[sb], db);}vector<pair<int, int>> path(2000);for (int i = 1; i <= idx; i ++) {auto res = bfs(i, 1);if (res.size() < path.size() && !res.empty()) path = res;res = bfs(i, 0);if (res.size() < path.size() && !res.empty()) path = res;}for (int i = path.size() - 1; i >= 1; i --) {cout << name[path[i].first] << " " << path[i].second << " ";cout << name[path[i - 1].first] << " " << path[i - 1].second << " ";}cout << "= " << name[path.back().first] << " " << path.back().second << " " << name[path[0].first] << " " << path[0].second;return 0;
}
5
//
// Created by trudbot on 2023/7/15.
//
#include <bits/stdc++.h>
using namespace std;int main () {int T; cin >> T;for (int t = 1; t <= T; t++) {int n; cin >> n;vector<int> s(n, 0);for (int i = 1; i <= n; i ++) {int a, b; cin >> a >> b;s[i] = 2 * a + 1 - b + 1;}vector<int> a(n);for (auto &x : a) cin >> x;vector<int> dp(4, 0);int mx = 0;for (auto &i : a) {dp[i] = max(dp[i] + 1, dp[i - 1] + 1);mx = max(mx, dp[i]);}cout << n - mx << endl;}return 0;
}