QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#177994#7107. Chaleurucup-team1359AC ✓196ms17024kbC++141.1kb2023-09-13 17:03:232023-09-13 17:03:24

Judging History

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

  • [2023-09-13 17:03:24]
  • 评测
  • 测评结果:AC
  • 用时:196ms
  • 内存:17024kb
  • [2023-09-13 17:03:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int T,n,m,u,v,s,ans1,ans2;
vector<int> edge[105000];
typedef pair<int,int> PII;
PII pii[105000];
int deg[105000];
int main() {
    scanf("%d",&T);
    while (T--) {
        scanf("%d%d",&n,&m);
        for (int i=1;i<=m;i++) {
            scanf("%d%d",&u,&v);
            edge[u].push_back(v);
            edge[v].push_back(u);
            deg[u]++;deg[v]++;
        }
        for (int i=1;i<=n;i++) pii[i]={deg[i],i};
        sort(pii+1,pii+1+n);
        reverse(pii+1,pii+1+n);
        s=ans1=ans2=0;
        for (int i=1;i<=n;i++) {
            if (pii[i].first>=i-1) s++;
            else break;
        }
        ans1++;
        for (int i=s+1;i<=n;i++) {
            if (pii[i].first==s-1) ans1++;
        }
        if (pii[s].first<=s) {
            for (int i=s;i>=1;i--) {
                if (pii[i].first==pii[s].first) ans2++;
            }
        }
        if (pii[s].first>=s) ans2++;
        cout<<ans1<<' '<<ans2<<endl;
        for (int i=1;i<=n;i++) {
            pii[i]={0,0};
            deg[i]=0;
            edge[i].clear();
        }
    }
    return 0;
}

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

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7192kb

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: 196ms
memory: 17024kb

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