QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#89052#5745. Graph Isomorphismchiranko#WA 438ms3356kbC++141.3kb2023-03-18 17:01:142023-03-18 17:01:17

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-18 17:01:17]
  • 评测
  • 测评结果:WA
  • 用时:438ms
  • 内存:3356kb
  • [2023-03-18 17:01:14]
  • 提交

answer

#include <bits/stdc++.h>
#define pb emplace_back

using namespace std;

using LL = long long;

const int maxn = 21;
const int maxk = (1 << maxn) + 5;
const LL mo = 1e9 + 9;

void solve()
{
	int n, m;
	cin >> n >> m;
	vector<int> deg(n + 1, 0), ea(m + 1, 0), eb(m + 1, 0);
	for(int i = 1; i <= m; ++i){
		int a, b;
		cin >> a >> b;
		ea[i] = a, eb[i] = b;
		++deg[a], ++deg[b];
	}	
	int fl = 0;
	for(int i = 1; i <= n; ++i){
		int t = min(deg[i], n - 1 - deg[i]);
		if(t > 0){
			fl = 1;
		}
	}
	
	
	if(n > 5){
		if(fl)
			cout << "NO\n";
		else{
			cout << "YES\n";
		}
	}
	else{
		int ans = 0;
		map<vector<array<int, 2>>, int> mp;
		vector<int> per(n, 0);
		for(int i = 0; i < n; ++i)
			per[i] = i + 1;
		do{
			vector<array<int, 2>> edge;
			for(int j = 1; j <= m; ++j){
				int a = per[ea[j] - 1];
				int b = per[eb[j] - 1];
				if(a > b)
					swap(a, b);
				array<int, 2> t = {a, b};
				edge.pb(t);
			}
			sort(edge.begin(), edge.end());
			if(mp.count(edge))
				continue;
			mp[edge] = 1;
			++ans;
		}while(next_permutation(per.begin(), per.end()));
		
		if(ans <= n){
			cout << "YES\n";
		}
		else{
			cout << "NO\n";
		}
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int T;
	cin >> T;

	
	while(T--){
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3348kb

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: 0
Accepted
time: 36ms
memory: 3356kb

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
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
...

result:

ok 39982 token(s): yes count is 39982, no count is 0

Test #3:

score: 0
Accepted
time: 106ms
memory: 3352kb

input:

33365
3 3
3 1
2 3
2 1
2 1
2 1
4 6
1 2
3 4
4 2
2 3
3 1
4 1
2 1
1 2
2 1
1 2
4 5
1 4
1 2
4 2
3 4
1 3
4 3
4 2
2 1
1 3
3 1
3 2
4 3
1 3
1 2
3 4
3 3
3 2
3 1
2 1
3 1
2 3
3 1
1 3
3 1
2 1
3 2
1 3
3 2
4 5
3 1
4 2
3 4
2 3
2 1
4 2
1 2
3 2
2 1
2 1
3 2
1 2
2 3
3 1
3 2
4 1
3 4
3 1
2 1
4 3
1 2
4 2
3 2
2 1
2 1
4 5
3 ...

output:

YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
NO
YES
YES
NO
YES
NO
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
...

result:

ok 33365 token(s): yes count is 25608, no count is 7757

Test #4:

score: 0
Accepted
time: 438ms
memory: 3316kb

input:

28572
3 3
1 3
2 1
3 2
2 1
1 2
4 1
4 2
3 2
1 2
2 3
5 2
4 3
4 2
2 1
2 1
3 1
1 3
5 10
1 3
3 5
1 2
4 3
4 5
4 1
5 1
4 2
2 5
3 2
4 4
2 1
1 3
2 4
1 4
2 1
1 2
4 4
1 3
4 2
4 1
2 1
4 3
1 4
3 1
4 2
5 2
2 1
4 5
4 1
3 4
5 5
2 5
3 1
4 1
2 3
1 5
5 3
5 4
3 5
2 3
4 1
4 3
3 2
2 3
1 2
2 1
2 1
4 5
3 2
3 4
4 1
3 1
2 1
3...

output:

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

result:

ok 28572 token(s): yes count is 19834, no count is 8738

Test #5:

score: -100
Wrong Answer
time: 300ms
memory: 3308kb

input:

22864
5 8
4 1
2 3
5 2
1 2
1 5
5 3
4 2
5 4
4 5
4 3
2 1
4 2
1 4
3 1
4 5
3 2
1 4
1 2
4 2
3 1
5 5
2 5
1 2
5 4
5 3
1 5
5 4
1 5
4 5
2 5
3 5
6 1
6 1
3 3
3 2
2 1
3 1
6 10
4 2
5 4
3 2
6 2
5 6
5 2
6 3
4 6
3 4
3 5
3 2
1 3
1 2
2 1
2 1
3 1
1 2
3 3
2 1
3 2
3 1
6 3
4 5
2 3
6 3
4 3
2 4
2 1
3 4
5 1
2 3
4 2
4 2
3 1
6...

output:

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

result:

wrong answer expected YES, found NO [8th token]