QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#546739 | #5745. Graph Isomorphism | pigstd | WA | 3ms | 5692kb | C++20 | 1.6kb | 2024-09-04 12:44:48 | 2024-09-04 12:44:48 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define vi vector<int>
#define vpi vector<pii>
#define all(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
const int M=1e5+10;
int n,m,deg[M],t[M];
vi e[M];
void solve()
{
n=read(),m=read();
for (int i=0;i<=n;i++)deg[i]=0,e[i].clear(),t[i]=0;
for (int i=1;i<=m;i++)
{
int u=read(),v=read();
e[u].pb(v),e[v].pb(u);
deg[u]++,deg[v]++;
}
for (int i=1;i<=n;i++)
t[deg[i]]++;
// for (int i=1;i<=n;i++)cout<<t[i]<<(i==n?'\n':' ');
int f=-1,f2=-1;
for (int i=0;i<=n;i++)
if (t[i]!=0)
{
if (t[i]==1)
{
if (f2==-1)f2=i;
else if (f==-1)f=1;
else return puts("NO"),void();
}
else
{
if (f==-1)f=1;
else return puts("NO"),void();
}
}
int tmp=n-1;
// cout<<"?:"<<f<<' '<<f2<<'\n';
if (f2!=-1)
{
deg[f2]=0;
for (auto x:e[f2])deg[x]--;
tmp--;
}
if (n<=4)return puts("YES"),void();
for (int i=1;i<=n;i++)
if (i!=f&&(deg[i]!=0&°[i]!=tmp))return puts("NO"),void();
puts("YES");
}
signed main()
{
int T=read();
while(T--)solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5600kb
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: 3ms
memory: 5672kb
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: 3ms
memory: 5692kb
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: -100
Wrong Answer
time: 3ms
memory: 3588kb
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 NO YES NO NO YES NO YES NO NO YES YES YES NO YES YES YES NO NO YES YES NO YES YES NO YES YES YES YES YES YES NO YES YES YES YES YES YES NO YES YES NO NO NO NO YES YES YES Y...
result:
wrong answer expected YES, found NO [37th token]