QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#84433 | #5523. Graph Problem With Small $n$ | kkio | WA | 2ms | 3500kb | C++14 | 615b | 2023-03-06 14:56:07 | 2023-03-06 14:57:49 |
Judging History
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'