QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88628#5745. Graph Isomorphismgalaxias#WA 12ms5932kbC++141.3kb2023-03-16 20:05:422023-03-16 20:05:45

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> G[N];

int a[5][5] , n , m , deg[N];

int read()
{
	int x;
	scanf("%d" , &x);
	return x;
}

bool force()
{
	for(int i = 1 ; i <= m ; ++ i)
	{
		int x = read() , y = read();
		a[x][y] = a[y][x] = 1;
	}
	int p[5];
	for(int i = 1 ; i <= n ; ++ i)
		p[i] = i;
	int cnt = 0;
	do
	{
		bool flag = true;
		for(int i = 1 ; i <= n ; ++ i)
			for(int j = 1 ; j <= n ; ++ j)
				if(a[i][j] && (!a[p[i]][p[j]])) flag = false;
		cnt += flag;
	}while(next_permutation(p + 1 , p + 1 + n));
	return cnt >= n;
}

bool solve()
{
	scanf("%d%d", &n, &m);
	if(n <= 4) return force();
	for(int i = 1; i <= n; i ++) deg[i] = 0;
	int mx = 0;
	for(int i = 1; i <= m; i ++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		deg[u] ++;
		deg[v] ++;
		mx = max(mx, deg[u]);
		mx = max(mx, deg[v]);
	}
	if(m == 1ll * n * (n - 1) / 2) return true;
	if(m == 0) return true;
	int cnt1 = 0 , cnt2 = 0;
	for(int i = 1 ; i <= n ; ++ i)
		cnt1 += (deg[i] == 1) , cnt2 += (deg[i] == n - 1);
	if((cnt1 == n - 1) && (cnt2 == 1)) return true;
	if((cnt1 == 1) && (cnt2 == n - 1)) return true;
	return false;
}

int main()
{
	int T;
	scanf("%d", &T);
	while(T --)
		if(solve()) puts("YES");
		else puts("NO");
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 5824kb

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: 12ms
memory: 5932kb

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:

NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
Y...

result:

wrong answer expected YES, found NO [1st token]