QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#752179 | #5307. Subgraph Isomorphism | einekleine18 | WA | 75ms | 3856kb | C++20 | 896b | 2024-11-15 22:33:54 | 2024-11-15 22:33:55 |
Judging History
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]