QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#669201#5745. Graph IsomorphismpropaneWA 142ms3796kbC++201.9kb2024-10-23 17:41:182024-10-23 17:41:18

Judging History

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

  • [2024-10-23 17:41:18]
  • 评测
  • 测评结果:WA
  • 用时:142ms
  • 内存:3796kb
  • [2024-10-23 17:41:18]
  • 提交

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() <= n ? "YES" : "NO") << '\n';
    }

}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

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: 3796kb

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: 38ms
memory: 3624kb

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: 142ms
memory: 3552kb

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: 94ms
memory: 3556kb

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

result:

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