QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#406721#5523. Graph Problem With Small $n$Jryno1WA 0ms3504kbC++141.1kb2024-05-07 17:07:162024-05-07 17:07:17

Judging History

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

  • [2024-05-07 17:07:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3504kb
  • [2024-05-07 17:07:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=30,maxs=(1<<24);
int G[maxn],t[maxs],dp[maxs],n;
int V[maxn];
int main(){
    cin.tie(0),cout.tie(0),ios::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            char s;
            cin>>s;
            if(s=='1')G[i]|=(1<<j);
        }
    }
    for(int S=0;S<(1<<n);S++){
        if(!(S&1))continue;
        for(int i=0;i<n;i++){
            if((1<<i)&S)t[S]|=G[i];
        }
    } 
    dp[1]=1;
    for(int S=0;S<(1<<n);S++){
        if(!dp[S]||(t[dp[S]]|S)==S)continue;
        for(int j=0;j<n;j++){
            if((1<<j)&S)continue;
            if(!((1<<j)&t[dp[S]]))continue;
            dp[S|(1<<j)]|=(1<<j);
        }
    }
    for(int S=0;S<(1<<n);S++){
        if(!(S&1))continue;
        int T=((1<<n)-1)^S;
        T|=1;
        for(int j=0;j<n;j++)if((1<<j)&dp[S])V[j]|=dp[T];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if((1<<j)&V[i])cout<<1;
            else cout<<0;
        }
        cout<<"\n";
    }
    return 0;
}

詳細信息

Test #1:

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

input:

4
0110
1010
1101
0010

output:

0000
0000
0000
0000

result:

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