QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#84316#5523. Graph Problem With Small $n$JWRuixiWA 2ms3304kbC++171.9kb2023-03-06 10:34:022023-03-06 10:34:04

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 10:34:04]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3304kb
  • [2023-03-06 10:34:02]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#define LL long long
#define writesp(x) write(x), putchar(' ')
#define writeln(x) write(x), putchar('\n')
#define lowbit(x) (x & (-x))
#define FileIO(ch) freopen(ch".in", "r", stdin), freopen(ch".out", "w", stdout)
using namespace std;

namespace IO {
    char ibuf[(1 << 20) + 1], *iS, *iT;
#if ONLINE_JUDGE
#define gh() (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, (1 << 20) + 1, stdin), (iS == iT ? EOF : *iS++) : *iS++)
#else
#define gh() getchar()
#endif
    inline long long read() {
        char ch = gh();
        long long x = 0;
        bool t = 0;
        while (ch < '0' || ch > '9') t |= ch == '-', ch = gh();
        while (ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = gh();
        return t ? ~(x - 1) : x;
    }
    inline void write(long long x) {
        if (x < 0) {
            x = ~(x - 1);
            putchar('-');
        }
        if (x > 9)
            write(x / 10);
        putchar((x % 10) | 48);
    }
}

using IO::read;
using IO::write;

const int maxs((1 << 24) + 7);
int n, to[maxs], f[maxs], ans[35];

int main() {
	n = read();
	for (int i = 0; i < n; i++) {
		char s[35];
		fread(s, 1, n + 1, stdin);
		for (int j = 0; j < n; j++) 
			if (s[j] == '1') to[1 << i] |= (1 << j); 
	}
	for (int s = 1; s < (1 << n); s++) {
		if (__builtin_popcount(s) <= 1) continue;
		to[s] = to[lowbit(s)] | to[s - lowbit(s)];
	}
	f[1] = 1;
	for (int s = 1; s < (1 << n); s++) {
		for (int i = 0; i < n; i++) {
			if (!f[s] || (s >> i) & 1 || !((to[f[s]] >> i) & 1)) continue;
			f[s | (1 << i)] |= (1 << i);
		}
	}
	for (int s = 0; s < (1 << n); s++) {
		for (int i = 0; i < n; i++) {
			if (!((f[s] >> i) & 1)) continue;
			ans[i] |= f[((1 << n) - 1 - s) | 1];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) write(ans[i] >> j & 1);
		puts("");
	}
}
// I love WHQ!

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
0110
1010
1101
0010

output:

0000
0000
0000
0000

result:

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