QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#797756#7107. Chaleurlichenyu_acAC ✓127ms4852kbC++14980b2024-12-03 17:37:402024-12-03 17:37:41

Judging History

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

  • [2024-12-03 17:37:41]
  • 评测
  • 测评结果:AC
  • 用时:127ms
  • 内存:4852kb
  • [2024-12-03 17:37:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;

int n,m;
int deg[N],p[N];
bool flag[N];

void solve(){
    scanf("%d%d",&n,&m);
    if(m==0)return printf("%d 1\n",n),void();
    for(int i=0;i<=n;i++)deg[i]=0,flag[i]=0;
    for(int i=1;i<=m;i++){
        int x,y;scanf("%d%d",&x,&y);
        deg[x]++,deg[y]++;
    }
    iota(p+1,p+n+1,1);
    sort(p+1,p+n+1,[&](int x,int y){
        return deg[x]>deg[y];
    });
    int sz=0;
    for(int i=1;i<=n;i++){
        int x=p[i];
        if(deg[x]>=sz)sz++,flag[x]=1;
        else break;
    }
    int ans=1;
    for(int i=1;i<=n;i++){
        if(!flag[i]&&deg[i]==sz-1)ans++;
    }
    printf("%d ",ans);
    int cnt1=0,cnt2=1;
    for(int i=1;i<=n;i++){
        if(!flag[i])continue;
        if(deg[i]==sz-1)cnt1++;
        else if(deg[i]==sz)cnt2++;
    }
    printf("%d\n",cnt1?cnt1:cnt2);
}

int main(){
    int T;scanf("%d",&T);
    while(T--)solve();
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3 2
1 2
2 3
6 6
1 2
2 3
1 3
1 4
2 5
3 6
4 1
1 2

output:

2 1
1 4
1 2

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 127ms
memory: 4852kb

input:

2231
1 0
5 7
4 1
3 4
3 1
3 5
4 2
3 2
4 5
5 4
2 1
2 5
2 4
2 3
5 10
3 2
2 5
1 4
4 2
4 5
1 2
1 3
3 5
3 4
1 5
5 10
1 3
2 4
1 4
5 2
2 3
1 5
5 4
1 2
3 4
5 3
5 9
2 5
3 5
2 3
2 1
4 3
3 1
4 1
4 5
2 4
5 4
4 2
4 1
4 5
4 3
5 9
4 1
4 5
3 4
2 4
2 1
3 1
2 5
3 5
3 2
5 4
2 5
2 3
2 1
2 4
5 9
5 2
1 3
4 3
1 2
5 4
4 2
5...

output:

1 1
3 1
4 1
1 5
1 5
2 1
4 1
2 1
4 1
2 1
2 1
3 1
4 1
4 1
1 5
2 1
4 1
1 5
1 5
1 5
3 1
4 1
4 1
4 1
3 1
3 1
4 1
4 1
2 1
4 1
4 1
1 5
1 5
2 1
4 1
4 1
4 1
3 1
2 1
4 1
2 1
4 1
4 1
4 1
3 1
1 5
4 1
4 1
1 5
2 1
4 1
2 1
2 1
1 5
4 1
1 5
3 1
4 1
1 5
2 1
1 5
3 1
3 1
1 5
3 1
3 1
2 1
1 5
4 1
3 1
1 5
2 1
3 1
2 1
2 1
...

result:

ok 2231 lines

Extra Test:

score: 0
Extra Test Passed