QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#84587#5523. Graph Problem With Small $n$sinsop90WA 2ms5456kbC++14886b2023-03-06 16:04:122023-03-06 16:04:43

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 16:04:43]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5456kb
  • [2023-03-06 16:04:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn = 25, maxS = (1 << 24) + 5;
int n, S, f[maxS], g[maxS], to[maxn], res[maxn];
char a[maxn][maxn];
int main() {
	scanf("%d", &n);
	S = (1 << n) - 1;
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= n;j++) cin >> a[i][j], to[i] |= ((a[i][j] - '0') << (j - 1));
		to[i] |= (1 << i - 1);
	}
	f[1] = 1;
	for(int i = 0;i <= S;i++) for(int j = 1;j <= n;j++) if((i >> (j - 1)) & 1 ^ 1) g[i | (1 << j - 1)] |= to[j];
	for(int i = 1;i <= S;i++){
		if(!f[i]) continue;
		for(int j = 1;j <= n;j++) if(((1 << j - 1) & g[f[i]]) && (!(1 << j - 1) & i)) f[i | (1 << j - 1)] |= (1 << j - 1);
	}
	for(int i = 1;i <= S;i+=2) for(int j = 1;j <= n;j++) if((f[i] >> (j - 1)) & 1) res[j] |= f[S - i + 1];
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= n;j++) printf(((res[i] >> (j - 1)) & 1) ? "1" : "0");
		puts("");
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 5456kb

input:

4
0110
1010
1101
0010

output:

0000
0000
0000
0000

result:

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