QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#669020 | #5745. Graph Isomorphism | propane | WA | 37ms | 3824kb | C++20 | 1.9kb | 2024-10-23 17:02:12 | 2024-10-23 17:02:18 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<set>
#include<numeric>
#include<algorithm>
using namespace std;
using LL = long long;
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int T;
cin >> T;
while(T--){
int n, m;
cin >> n >> m;
vector<pair<int, int> > edge(m);
for(int i = 0; i < m; i++){
int a, b;
cin >> a >> b;
a--, b--;
if (a > b) swap(a, b);
edge[i] = {a, b};
}
if (1LL * n * (n - 1) / 2 == m or m == 0){
cout << "YES" << '\n';
continue;
}
if (n > 5){
vector<int> d(n);
for(auto [x, y] : edge){
d[x] += 1;
d[y] += 1;
}
if (m == 1LL * (n - 1) * (n - 2) / 2){
int t = 0;
while(t < n and d[t] != 0) t++;
cout << (t == n ? "NO" : "YES") << '\n';
}
else if (m == n - 1){
int t = 1;
while(t < n and d[t] != n - 1) t++;
cout << (t == n ? "NO" : "YES") << '\n';
}
else{
cout << "NO" << '\n';
}
continue;
}
vector<int> id(n);
iota(id.begin(), id.end(), 0);
set<vector<pair<int, int> > > s;
do{
auto nedge = edge;
for(auto &[x, y] : nedge){
x = id[x];
y = id[y];
if (x > y) swap(x, y);
}
sort(nedge.begin(), nedge.end());
s.insert(nedge);
}while(next_permutation(id.begin(), id.end()));
cout << (s.size() <= 10 ? "YES" : "NO") << '\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
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: 12ms
memory: 3628kb
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: -100
Wrong Answer
time: 37ms
memory: 3824kb
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 YES NO YES NO YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES NO YES NO YES YES YES NO YES YES YES YES NO YES NO YES YES YES YES NO YES YES YES ...
result:
wrong answer expected NO, found YES [6th token]