QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#546737#5745. Graph IsomorphismpigstdWA 4ms5772kbC++201.6kb2024-09-04 12:41:472024-09-04 12:41:47

Judging History

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

  • [2024-09-04 12:41:47]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:5772kb
  • [2024-09-04 12:41:47]
  • 提交

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 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&&deg[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: 5700kb

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: 4ms
memory: 5688kb

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: 4ms
memory: 5772kb

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

result:

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