QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#120323 | #5745. Graph Isomorphism | UrgantTeam# | WA | 1ms | 3460kb | C++23 | 1.1kb | 2023-07-06 16:45:00 | 2023-07-06 16:45:03 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using vi = vector<int>;
using ll = int64_t;
using pii = pair<int, int>;
using vpii = vector<pii>;
int find_ans(const int n, const vpii& e) {
vi d(n);
for (pii f : e) {
++d[f.first];
++d[f.second];
}
int k0 = 0, k1 = 0, m0 = 0, m1 = 0;
for (int i : d) {
if (i == 0) ++k0;
if (i == 1) ++k1;
if (i == n - 1) ++m0;
if (i == n - 2) ++m1;
}
if (k0 + m1 == n) return true;
if (m0 + k1 == n) return true;
if (k0 || m0) return false;
return n == 4;
}
void solve_test() {
int n, m;
cin >> n >> m;
vpii e(m);
for (int i = 0; i < m; ++i) {
cin >> e[i].first >> e[i].second;
--e[i].first; --e[i].second;
}
cout << (find_ans(n, e) ? "YES\n" : "NO\n");
}
void solve_tests() {
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
solve_test();
}
}
int main() {
#ifdef ONPC
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve_tests();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3460kb
input:
3 3 3 1 2 2 3 3 1 3 2 1 2 2 3 5 5 1 2 2 3 3 4 4 5 5 1
output:
YES YES NO
result:
ok 3 token(s): yes count is 2, no count is 1
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3400kb
input:
39982 3 2 2 1 3 2 2 1 1 2 2 1 2 1 3 3 3 1 2 3 1 2 2 1 1 2 3 3 3 1 3 2 2 1 2 1 1 2 3 2 1 2 3 1 3 3 2 1 3 1 2 3 2 1 1 2 3 2 2 1 3 2 3 3 2 3 3 1 2 1 3 3 2 1 1 3 2 3 3 3 3 1 3 2 1 2 2 1 2 1 2 1 2 1 3 1 3 1 2 1 2 1 2 1 1 2 3 2 1 3 3 2 3 2 1 2 1 3 3 2 3 2 1 3 2 1 1 2 3 2 3 2 3 1 3 3 2 3 3 1 1 2 2 1 1 2 3 ...
output:
YES NO NO YES NO YES NO YES YES NO YES YES YES YES NO NO YES NO NO YES YES YES NO YES YES NO YES NO YES NO NO NO YES NO YES NO YES YES NO NO NO NO YES YES YES YES NO NO NO NO YES NO NO NO YES NO YES YES NO YES NO YES YES YES YES NO NO NO YES NO YES NO YES YES YES NO NO NO YES YES YES YES NO YES NO Y...
result:
wrong answer expected YES, found NO [2nd token]