QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#84371#5523. Graph Problem With Small $n$AlkaidRE 2ms3332kbC++141.0kb2023-03-06 12:57:102023-03-06 12:57:14

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 12:57:14]
  • 评测
  • 测评结果:RE
  • 用时:2ms
  • 内存:3332kb
  • [2023-03-06 12:57:10]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 25;
const int M = (1 << 25) + 10;

int n, dp[N], G[N], f[N], g[N];

signed main() {
    cin >> n;

    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for(int j = 0; j < n; j++) {
            if(s[j] == '1')
                G[i] |= 1 << j;
        }
    }

    g[1] = 1;
    
    for(int S = 1; S < (1 << n); S++) {
        for(int i = 0; i < n; i++) {
            if(S >> i & 1)
                continue;
            if(g[S] & G[i])
                g[S | (1 << i)] |= 1 << i;
        }
    }

    for(int S = 1; S < (1 << n); S++) {
        if(!(S & 1))
            continue;
        for(int i = 0; i < n; i++) {
            if(g[S] & (1 << i))
                dp[i] |= g[(1 << n) - S];
        }
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(dp[i] & (1 << j))
                cout << 1;
            else
            cout << 0;
        }
        cout << endl;
    }
}

詳細信息

Test #1:

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

input:

4
0110
1010
1101
0010

output:

0001
0001
0000
1100

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 2ms
memory: 3304kb

input:

6
010001
101000
010100
001010
000101
100010

output:

010001
101000
010100
001010
000101
100010

result:

ok 6 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 3284kb

input:

4
0111
1011
1101
1110

output:

0111
1011
1101
1110

result:

ok 4 lines

Test #4:

score: -100
Runtime Error

input:

23
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000...

output:


result: