QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#669013#5745. Graph IsomorphismpropaneWA 41ms3612kbC++201.9kb2024-10-23 17:00:432024-10-23 17:00:48

Judging History

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

  • [2024-10-23 17:00:48]
  • 评测
  • 测评结果:WA
  • 用时:41ms
  • 内存:3612kb
  • [2024-10-23 17:00:43]
  • 提交

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;
            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 + 1);
            for(auto [x, y] : edge){
                d[x] += 1;
                d[y] += 1;
            }
            if (m == 1LL * (n - 1) * (n - 2) / 2){
                int t = 1;
                while(t <= n and d[t] != 0) t++;
                cout << (t == n + 1 ? "NO" : "YES") << '\n';
            }
            else if (m == n - 1){
                int t = 1;
                while(t <= n and d[t] != n - 1) t++;
                cout << (t == n + 1 ? "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: 3540kb

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: 8ms
memory: 3544kb

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: 41ms
memory: 3612kb

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

result:

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