QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#161637#7107. Chaleurucup-team987#AC ✓133ms17300kbC++201.4kb2023-09-03 00:59:252023-09-03 00:59:25

Judging History

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

  • [2023-09-03 00:59:25]
  • 评测
  • 测评结果:AC
  • 用时:133ms
  • 内存:17300kb
  • [2023-09-03 00:59:25]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;
int N,M;
vector<int>G[1<<17];
int ex[1<<17];
bool inQ[1<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;cin>>T;
	for(;T--;)
	{
		cin>>N>>M;
		for(int i=0;i<N;i++)
		{
			G[i].clear();
			ex[i]=0;
			inQ[i]=false;
		}
		for(int i=0;i<M;i++)
		{
			int a,b;cin>>a>>b;
			a--,b--;
			G[a].push_back(b);
			G[b].push_back(a);
		}
		vector<int>Vid(N);
		for(int i=0;i<N;i++)Vid[i]=i;
		sort(Vid.begin(),Vid.end(),[](int l,int r){return G[l].size()>G[r].size();});
		vector<int>Q;
		for(int u:Vid)if(ex[u]==Q.size())
		{
			Q.push_back(u);
			inQ[u]=true;
			for(int v:G[u])ex[v]++;
		}
		//cout<<"Qlique :";for(int u:Q)cout<<" "<<u+1;cout<<endl;
		{//Qlique
			int mxsize=Q.size(),cnt=1;
			for(int u=0;u<N;u++)if(!inQ[u])
			{
				int d=G[u].size();
				int nsz=Q.size();
				if(d==Q.size())nsz++;
				else if(d+1<Q.size())continue;
				if(mxsize<nsz)mxsize=nsz,cnt=0;
				if(mxsize==nsz)cnt++;
			}
			cout<<cnt<<" ";
		}
		{//Anti Qlique
			int mxsize=N-Q.size(),cnt=1;
			for(int u=0;u<N;u++)if(inQ[u])
			{
				int d=G[u].size();
				int nsz=N-Q.size();
				if(d+1==Q.size())nsz++;
				else if(d+1==Q.size()+1);
				else continue;
				if(mxsize<nsz)mxsize=nsz,cnt=0;
				if(mxsize==nsz)cnt++;
			}
			cout<<cnt<<"\n";
		}
	}
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 133ms
memory: 17300kb

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