QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#159269#7107. Chaleurucup-team1338#AC ✓53ms4688kbC++17936b2023-09-02 17:43:132023-09-02 17:43:14

Judging History

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

  • [2023-09-02 17:43:14]
  • 评测
  • 测评结果:AC
  • 用时:53ms
  • 内存:4688kb
  • [2023-09-02 17:43:13]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
using namespace std;
const LL N=1e5+9;
LL n,m;
LL d[N];
template<typename T>
inline void read(T &x)
{
	x=0;T w=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')w=-1;	c=getchar();}
	while(isdigit(c)){x=x*10+(c^'0');	c=getchar();}
	if(w==-1)	x=-x;
}
template<typename T,typename... Args>
inline void read(T &x,Args &...args)
{
	read(x),read(args...);
}
LL calc()
{
	sort(d+1,d+n+1,greater<LL>());
	LL a,ans=1;
	for(LL i=n;i>=1;--i)
	{
		if(d[i]>=i-1)
		{
			a=i;
			break;
		}
	}
	for(LL i=a+1;i<=n;++i)
		if(d[i]==a-1)	++ans;
	return ans;
}
void solve()
{
	read(n,m);
	for(LL i=1;i<=n;++i)
		d[i]=0;
	for(LL i=1,u,v;i<=m;++i)
	{
		read(u,v);
		++d[u],++d[v];
	}
	LL ans1=calc();
	for(LL i=1;i<=n;++i)
		d[i]=n-1-d[i];
	LL ans2=calc();
	printf("%lld %lld\n",ans1,ans2);
}
int main()
{
	LL T;
	read(T);
	while(T--)	solve();
	return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 53ms
memory: 4688kb

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