QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#84433#5523. Graph Problem With Small $n$kkioWA 2ms3500kbC++14615b2023-03-06 14:56:072023-03-06 14:57:49

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-06 14:57:49]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3500kb
  • [2023-03-06 14:56:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=24;
int dp[1<<24];
int n,s[24];
int main()
{
	scanf("%d",&n); 
	for(int i=0;i<n;i++)
	{
		char ss[50];
		scanf("%s",ss);
		for(int j=0;j<n;j++)
			s[i]|=(ss[j]-'0')<<j;
	}
	dp[1]=1;
	for(int i=0;i<(1<<n);i++)
		for(int j=0;j<n;j++)
			if(dp[i])
			{
				if(!(i&(1<<j))&&(dp[i]&s[j]))
					dp[i|(1<<j)]|=(1<<j);
			} 
	for(int i=0;i<n;i++)
	{
		int G=0;
		for(int j=1;j<(1<<n);j+=2)
			if(dp[j]&(1<<i))
			{
				int R=(1<<n)-1-j;
				G|=dp[R];
			}
		for(int j=0;j<n;j++)
			printf("%d",(G>>j)&1);
		putchar('\n');
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
0110
1010
1101
0010

output:

0000
0000
0000
0000

result:

wrong answer 1st lines differ - expected: '0001', found: '0000'