QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#158921#7107. Chaleurucup-team1448#AC ✓151ms4576kbC++14936b2023-09-02 17:12:582023-09-02 17:12:58

Judging History

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

  • [2023-09-02 17:12:58]
  • 评测
  • 测评结果:AC
  • 用时:151ms
  • 内存:4576kb
  • [2023-09-02 17:12:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,d[N],ans1,ans2,t;
int a[N];
int main(){
    int T;scanf("%d",&T);
    while(T--){
        scanf("%d%d",&n,&m);ans1=ans2=0;
        for(int i=1;i<=n;++i) d[i]=0,a[i]=i;
        for(int i=1,u,v;i<=m;++i) scanf("%d%d",&u,&v),++d[u],++d[v];
        sort(a+1,a+n+1,[&](int A,int B){return d[A]>d[B];});
        for(int i=n;i;--i)
            if(d[a[i]]>=i-1){
                t=i;
                break;
            }
        // printf("t=%d\n",t);
        // for(int i=1;i<=n;++i) printf("%d ",d[a[i]]);puts("");
        ans1=1;
        for(int i=t+1;i<=n;++i) if(d[a[i]]>=t-1) ++ans1;
        for(int i=1;i<=t;++i) if(d[a[i]]==t-1) ans2++;
        if(!ans2){
            ans2=1;
            if(d[a[t]]==t) 
                for(int i=1;i<=n;++i) if(d[a[i]]==t) ++ans2;
        }
        printf("%d %d\n",ans1,ans2);
    }
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3976kb

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: 151ms
memory: 4576kb

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