QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#752179#5307. Subgraph Isomorphismeinekleine18WA 75ms3856kbC++20896b2024-11-15 22:33:542024-11-15 22:33:55

Judging History

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

  • [2024-11-15 22:33:55]
  • 评测
  • 测评结果:WA
  • 用时:75ms
  • 内存:3856kb
  • [2024-11-15 22:33:54]
  • 提交

answer

#include<bits/stdc++.h>
#include <vector>

#define int long long
void slove(){
    int n,m;
    std::cin>>n>>m;
    std::vector g(n,std::set<int>());
    for(int i=0;i<m;++i){
        int a,b;
        std::cin>>a>>b;
        --a,--b;
        g[a].insert(b);
        g[b].insert(a);
    }
    m=0;
    for(int i=0;i<n;++i){
        m+=g[i].size();
    }
    m/=2;
    int f=0;
    if(m==n-1){
        f=1;
    }else if(m==n){
        f=1;
        for(int i=0;i<n;++i){
            if((int)g[i].size()!=2){
                f=0;
            }
        }
    }
    std::cout<<(f?"YES\n":"NO\n");
}
signed main(){
#ifdef LOCAL
    std::freopen("in.txt","r",stdin);
    std::freopen("out.txt","w",stdout);
#endif
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int _=1;
    std::cin>>_;
    for(int i=0;i<_;++i){
        slove();
    }
}

詳細信息

Test #1:

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

input:

4
7 6
1 2
2 3
3 4
4 5
5 6
3 7
3 3
1 2
2 3
3 1
5 5
1 2
2 3
3 4
4 1
1 5
1 0

output:

YES
YES
NO
YES

result:

ok 4 token(s): yes count is 3, no count is 1

Test #2:

score: -100
Wrong Answer
time: 75ms
memory: 3856kb

input:

33192
2 1
1 2
3 2
1 3
2 3
3 3
1 2
1 3
2 3
4 3
1 4
2 4
3 4
4 3
1 3
1 4
2 4
4 4
1 3
1 4
2 4
3 4
4 4
1 3
1 4
2 3
2 4
4 5
1 3
1 4
2 3
2 4
3 4
4 6
1 2
1 3
1 4
2 3
2 4
3 4
5 4
1 5
2 5
3 5
4 5
5 4
1 4
1 5
2 5
3 5
5 5
1 4
1 5
2 5
3 5
4 5
5 5
1 4
1 5
2 4
3 5
4 5
5 5
1 4
1 5
2 4
2 5
3 5
5 6
1 4
1 5
2 4
2 5
3 ...

output:

YES
YES
YES
YES
YES
NO
YES
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
N...

result:

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