QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#282464#5523. Graph Problem With Small $n$duckierWA 175ms3676kbC++141.1kb2023-12-12 07:31:582023-12-12 07:31:59

Judging History

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

  • [2023-12-12 07:31:59]
  • 评测
  • 测评结果:WA
  • 用时:175ms
  • 内存:3676kb
  • [2023-12-12 07:31:58]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int MAXN = 24;
int n, dp[1LL << MAXN], adj[MAXN], ans[MAXN];
string s[MAXN];
bool istheone = false;

signed main() {
	cin.tie(NULL)->sync_with_stdio(0);
	cin >> n;
	if (n > 20)istheone = true;
	for (int i = 1; i <= n; i++) cin >> s[i];
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i][j] == '1') adj[i] ^= 1LL << j;
		}
	}
	dp[1] = 1;
	for (int i = 2; i < 1LL << n; i++) {
		for (int j = 0; j < n; j++) {
			if (dp[i ^ (1LL << j)] & adj[j + 1]) {
				dp[i] |= 1LL << j;
			}
		}
	}
	for (int c = 1; c <= n; c++) {
		for (int i = 1; i < 1LL << n; i++) {
			if (!(dp[i] & (1LL << (c - 1))))continue;
			int comp = (((1LL << n) - 1) ^ i) + 1;
			ans[c] |= dp[comp];
		}
	}
	if (istheone)return 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n; j++) {
			if (ans[i] & (1LL << j)) {
				cout << '1';
			}
			else {
				cout << '0';
			}
		}
		cout << '\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

4
0110
1010
1101
0010

output:

0001
0001
0000
1100

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3676kb

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: 0ms
memory: 3588kb

input:

4
0111
1011
1101
1110

output:

0111
1011
1101
1110

result:

ok 4 lines

Test #4:

score: -100
Wrong Answer
time: 175ms
memory: 3676kb

input:

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

output:


result:

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