QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#120323#5745. Graph IsomorphismUrgantTeam#WA 1ms3460kbC++231.1kb2023-07-06 16:45:002023-07-06 16:45:03

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-06 16:45:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3460kb
  • [2023-07-06 16:45:00]
  • 提交

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]