QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#84371 | #5523. Graph Problem With Small $n$ | Alkaid | RE | 2ms | 3332kb | C++14 | 1.0kb | 2023-03-06 12:57:10 | 2023-03-06 12:57:14 |
Judging History
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...