QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226184#7107. Chaleurfzj2007AC ✓37ms16156kbC++141.5kb2023-10-25 17:51:512023-10-25 17:51:51

Judging History

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

  • [2023-10-25 17:51:51]
  • 评测
  • 测评结果:AC
  • 用时:37ms
  • 内存:16156kb
  • [2023-10-25 17:51:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
	x=0;
	char ch=getchar();
	bool flag=0;
	while(ch>'9'||ch<'0') flag=flag||ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=flag?-x:x;
}
template<typename T,typename ...Args>inline void read(T &x,Args &...args){
	read(x),read(args...);
}
template<typename T>inline void prt(T x){
	if(x>9) prt(x/10);
	putchar(x%10+'0');
}
template<typename T>inline void put(T x){
	if(x<0) putchar('-'),x=-x;
	prt(x);
}
template<typename T>inline void put(char ch,T x){
	put(x),putchar(ch);
}
template<typename T,typename ...Args>inline void put(char ch,T x,Args ...args){
	put(ch,x),put(ch,args...);
}
#define N 100005
vector<int> e[N];
int t[N],vis[N];
int n,m;
inline void solve(){
	read(n,m);
	for(int i=1,u,v;i<=m;i++)
		read(u,v),e[u].emplace_back(v),e[v].emplace_back(u);
	for(int i=1;i<=n;i++) t[e[i].size()]++;
	for(int i=n;i;i--) t[i-1]+=t[i];
	int mx=1,num=0;
	while(t[mx]>=mx+1) mx++;
	for(int i=1;i<=n;i++)
		if(e[i].size()>mx-1) vis[i]=1,num++; 
	for(int i=1;i<=n;i++)
		if(e[i].size()==mx-1&&num<mx) vis[i]=1,num++;
	put(' ',t[mx-1]-mx+1);
	int ans=0;
	for(int i=1;i<=n;i++)
		if(vis[i]&&e[i].size()==mx-1) ans++;
	if(!ans){
		ans=1;
		for(int i=1;i<=n;i++)
			if(vis[i]&&e[i].size()==mx) ans++;
	}	
	put('\n',ans);	
	for(int i=0;i<=n;i++) t[i]=0;
	for(int i=1;i<=n;i++) e[i].clear(),vis[i]=0;
}
int T;
int main(){
	read(T);
	while(T--) solve();
	return 0;
}

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

詳細信息

Test #1:

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

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: 37ms
memory: 16156kb

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