Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
54351 _ 凯妹的考验 C++ 解答错误 10 23 MS 904 KB 1191 2022-08-01 11:33:15

Tests(1/10):


#include <bits/stdc++.h> using namespace std; const int MXN = 100005; int fa[MXN << 1], N, M, anssize; char ans[MXN]; int find(int x) { return x ^ fa[x] ? fa[x] = find(fa[x]) : x; } int main() { scanf("%d%d", &N, &M); for (int i(0); i != N * 2; ++i) fa[i] = i; for (int t(0), x(0), y(0); M--;) { scanf("%d%d%d", &t, &x, &y); --x, --y; if (t == 1) { fa[find(x)] = find(y); fa[find(x + N)] = find(y + N); if (find(x) == find(x + N)) { puts("ORZKsister"); return 0; } } if (t == 2) { fa[find(x)] = find(y + N); fa[find(x + N)] = find(y); if (find(x) == find(x + N)) { puts("ORZKsister"); return 0; } } if (t == 3) { if (find(x) == find(y)) ans[anssize++] = 'Z'; else if (find(x) == find(y + N)) ans[anssize++] = 'J'; else ans[anssize++] = 'K'; } } printf("%d\n", anssize); for (int i(0); i != anssize; ++i) putchar(ans[i]), putchar(10); return 0; }


测评信息: