QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#80112 | #5523. Graph Problem With Small $n$ | WTR2007 | WA | 2ms | 3536kb | C++14 | 1.4kb | 2023-02-22 12:42:12 | 2023-02-22 12:42:15 |
Judging History
answer
#include<bits/stdc++.h>
#define MULT_TEST 0
using namespace std;
const int INF = 0x3f3f3f3f;
const int M = 24;
const int N = (1 << M);
char tmp[M];
int dp[N], to[M];
inline int read() {
int w = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if(ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
w = (w << 1) + (w << 3) + ch - 48;
ch = getchar();
}
return w * f;
}
inline void Solve() {
int n;
n = read();
for (int i = 0; i < n; i++) {
scanf("%s", tmp);
for (int j = 0; j < n; j++) to[i] |= (tmp[j] - '0') * (1 << j);
cout << to[i] << endl;
}
dp[1] = 1;
for (int S = 2; S < (1 << n); S++) {
for (int i = 0; i < n; i++) {
if (!((S >> i) & 1)) continue;
if (dp[S - (1 << i)] & to[i]) dp[S] |= (1 << i);
}
}
for (int i = 0; i < n; i++) {
int ans = 0;
for (int S = 0; S < (1 << n); S++) {
if (!((S >> i) & 1)) continue;
ans |= dp[(1 << n) - S] & to[i];
}
for (int j = 0; j < n; j++) {
if ((ans >> j) & 1) printf("1");
else printf("0");
}
puts("");
}
}
signed main() {
int T = 1;
#if MULT_TEST
T = read();
#endif
while (T--) Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3536kb
input:
4 0110 1010 1101 0010
output:
6 5 11 4 0110 1010 1100 0010
result:
wrong answer 1st lines differ - expected: '0001', found: '6'