QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#667211#9246. Dominating PointwysunWA 0ms3500kbC++141.4kb2024-10-22 21:38:102024-10-22 21:38:38

Judging History

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

  • [2024-11-22 18:38:25]
  • hack成功,自动添加数据
  • (/hack/1238)
  • [2024-10-22 21:38:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3500kb
  • [2024-10-22 21:38:10]
  • 提交

answer

#include<iostream>
#include<vector>
#include<cstring>

using namespace std;

const int N=5e3+10;

bool m[N][N];
int a,b,c;
int s[N];

int main()
{
	int n;
	cin>>n;
	
	int a,maxa=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			char ch;
			cin>>ch;
			
			m[i][j] = (ch == '1');
			s[i] += (ch == '1');
		}
		if(maxa<s[i])
		{
			maxa = s[i];
			a = i;
		}
	}
	
	if(maxa == n - 1)
	{
		cout<<"NOT FOUND"<<endl;
		return 0;
	}
	
	vector<int> v;
	for(int i=1;i<=n;i++)
		if(m[i][a])
			v.push_back(i);
	
	int maxb=0,b;
	memset(s,0,sizeof s);		
	for(auto x : v)
	{
		for(auto y : v)
		{
			if(m[x][y])
				s[x] ++;
		}
		if(s[x]>maxb)
		{
			maxb = s[x];
			b=x;
		}
	}
	if(v.size() == 1) b = v[0];
	
	int c;
	if(maxb != v.size() - 1)
	{
		vector<int> w;
		for(auto x : v)
			if(m[x][b])
				w.push_back(x);
		
		int maxc=0;
		memset(s,0,sizeof s);
		for(auto x : w)
		{
			for(auto y : w)
				if(m[x][y])
					s[x]++;
			
			if(maxc < s[x])
			{
				c = x;
				maxc = s[x];
			}		
		}
	}
	else
	{
		vector<int> w;
		for(int j=1;j<=n;j++)
			if(m[a][j])
				w.push_back(j);
				
		int maxc=0;		
		memset(s,0,sizeof s);
		for(auto x : w)
		{
			for(auto y : w)
				if(m[x][y])
					s[x]++;
			
			if(maxc < s[x])
			{
				c = x;
				maxc = s[x];
			}	
		}
	}
	
	cout<<a<<' '<<b<<' '<<c<<endl;
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3500kb

input:

6
011010
000101
010111
100001
010100
100010

output:

3 1 2

result:

wrong answer Wrong Answer, Point not dominating.