QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#184600#7107. Chaleurliuzhenhao09#AC ✓149ms4584kbC++20747b2023-09-20 22:02:302023-09-20 22:02:31

Judging History

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

  • [2023-09-20 22:02:31]
  • 评测
  • 测评结果:AC
  • 用时:149ms
  • 内存:4584kb
  • [2023-09-20 22:02:30]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,n,m;
int deg[100010];
signed main(){
	scanf("%lld",&T);
	while(T--){
		memset(deg,0,sizeof(deg));
		scanf("%lld %lld",&n,&m);
		for(int i = 1,u,v; i <= m; i++){
			scanf("%lld %lld",&u,&v);
			deg[u]++,deg[v]++;
		}
		sort(deg + 1,deg + n + 1);
		int cnt = 0,ans1 = 1,ans2 = 1;
		for(int i = n; i >= 1; i--){
			if(deg[i] >= cnt) cnt++;
		}
		int cntt = 0;
		int ans3 = 0;
		for(int i = n; i >= 1; i--){
			if(deg[i] >= cntt){
				cntt++;
				if(deg[i] == cnt - 1) ans3++;
				else if(deg[i] == cnt) ans2++;
			}
			else{
				if(deg[i] == cnt - 1) ans1++;
			}
		}
		if(ans3) ans2 = ans3;
		printf("%lld %lld\n",ans1,ans2);
	}
	return 0;
}

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

詳細信息

Test #1:

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

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: 149ms
memory: 4584kb

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