比赛 |
国庆欢乐赛2 |
评测结果 |
TTTTTWWEWWWWWWEWWWWWWWEWW |
题目名称 |
追忆 |
最终得分 |
0 |
用户昵称 |
LikableP |
运行时间 |
53.547 s |
代码语言 |
C++ |
内存使用 |
5.64 MiB |
提交时间 |
2025-10-04 11:58:35 |
显示代码纯文本
#include <iostream>
#include <cstring>
using namespace std;
class solution1 {
public:
const static int MAXN = 2010;
const static int MAXM = 4010;
struct EDGE {
int v, next;
} edge[MAXM];
int head[MAXN], edgeNum;
void AddEdge(int u, int v) {
edge[++edgeNum] = {v, head[u]};
head[u] = edgeNum;
}
int n, m, q;
int a[MAXN], b[MAXN];
bool vis[MAXN];
int ans;
void dfs(int u, int l, int r) {
if (vis[u]) return ;
vis[u] = 1;
if (l <= a[u] && a[u] <= r) {
ans = max(ans, b[u]);
}
for (int i = head[u]; i; i = edge[i].next) {
dfs(edge[i].v, l, r);
}
}
solution1() {
cin >> n >> m >> q;
for (int i = 1, u, v; i <= m; ++i) {
cin >> u >> v;
AddEdge(u, v);
}
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
for (int i = 1; i <= n; ++i) {
cin >> b[i];
}
for (int o, x, y, l, r; q--; ) {
cin >> o;
if (o == 1) {
cin >> x >> y;
swap(a[x], a[y]);
} else if (o == 2) {
cin >> x >> y;
swap(b[x], b[y]);
} else if (o == 3) {
cin >> x >> l >> r;
ans = 0;
memset(vis, 0, sizeof vis);
dfs(x, l, r);
cout << ans << endl;
}
}
}
};
class solution2 {
public:
const static int MAXN = 1e5 + 10;
const static int MAXM = 2e5 + 10;
struct EDGE {
int v, next;
} edge[MAXM];
int head[MAXN], edgeNum;
void AddEdge(int u, int v) {
edge[++edgeNum] = {v, head[u]};
head[u] = edgeNum;
}
int n, m, q;
int a[MAXN], b[MAXN];
solution2() {
cin >> n >> m >> q;
for (int i = 1, u, v; i <= m; ++i) {
cin >> u >> v;
AddEdge(u, v);
}
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
for (int i = 1; i <= n; ++i) {
cin >> b[i];
}
for (int o, x, y, l, r; q--; ) {
cin >> o;
if (o == 1) {
cin >> x >> y;
} else if (o == 2) {
cin >> x >> y;
} else if (o == 3) {
cin >> x >> l >> r;
cout << "Ciallo~(∠・ω< )⌒★" << endl;
}
}
}
};
int main() {
freopen("recall.in", "r", stdin);
freopen("recall.out", "w", stdout);
cin.tie(0)->sync_with_stdio(false), cout.tie(0);
int c, T;
cin >> c >> T;
while (T--) {
if (0 <= c && c <= 5) {solution1 *x = new solution1; delete x;}
else {solution2 *x = new solution2; delete x;}
}
return 0;
}