QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#411690#5523. Graph Problem With Small $n$DYSisNoobTL 1393ms174872kbC++141.1kb2024-05-15 18:03:142024-05-15 18:03:15

Judging History

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

  • [2024-05-15 18:03:15]
  • 评测
  • 测评结果:TL
  • 用时:1393ms
  • 内存:174872kb
  • [2024-05-15 18:03:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin >> n;
	vector<int> m(n + 1), vis(1 << n), dp(1 << n), ans(n + 1);
	for (int i = 1; i <= n; i++)
	{
		string s;
		cin >> s;
		for (int j = 0; j < s.length(); j++)
		{
			if (s[j] == '1')  m[i] += (1 << j);
		}
	}
	dp[1] = 1;
	queue<int> q;
	q.push(1);
	while (!q.empty())
	{
		int cur = q.front();
		q.pop();
		if (vis[cur])  continue;
		vis[cur] = 1;
		for (int i = 1; i <= n; i++)
		{
			if (!(cur & (1 << (i - 1))) && (dp[cur] & m[i]))
			{
				dp[cur + (1 << (i - 1))] |= (1 << (i - 1));
				if (!vis[cur + (1 << (i - 1))])  q.push(cur + (1 << (i - 1)));
			}
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < (1 << n); j++)
		{
			if (!(j & (1 << (i - 1))) || !(j & 1) || !(dp[j] & (1 << (i - 1))))  continue;
			ans[i] |= dp[(1 << n) - j];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		int cnt = 0;
		while (ans[i])
		{
			cout << (ans[i] & 1);
			ans[i] >>= 1;
			cnt++;
		}
		for (int j = cnt + 1; j <= n; j++)
		{
			cout << 0;
		}
		cout << '\n';
	}
	return 0;
}

详细

Test #1:

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

input:

4
0110
1010
1101
0010

output:

0001
0001
0000
1100

result:

ok 4 lines

Test #2:

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

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: 3672kb

input:

4
0111
1011
1101
1110

output:

0111
1011
1101
1110

result:

ok 4 lines

Test #4:

score: 0
Accepted
time: 170ms
memory: 68604kb

input:

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

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #5:

score: 0
Accepted
time: 171ms
memory: 68696kb

input:

23
00010100000000000101000
00000000010000000001000
00000000000001000000001
10000000000000000010000
00000000000000000000000
10000000000000000000000
00000001000000000000000
00000010000000000010000
00000000000001000000000
01000000000000000000000
00000000000000000000000
00000000000000000000000
000000000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #6:

score: 0
Accepted
time: 172ms
memory: 68688kb

input:

23
00001000000000000000000
00001000010001000000000
00000000000101000010000
00001000000100000000000
11010000010011000100000
00000000000100000000000
00000000000000000000001
00000000000000000101000
00000000000000000000000
01001000000000101010010
00000000000000000000101
00110100000010001000000
000010000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #7:

score: 0
Accepted
time: 177ms
memory: 68684kb

input:

23
01000000000001101001100
10000001101000000000000
00000100000100010000100
00000000000000001011000
00000100001000000000000
00101000000000001000001
00000000000000000000000
01000000000000000000000
01000000000100000010000
00000000000001000000011
01001000000000010000000
00100000100001000100001
000000000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #8:

score: 0
Accepted
time: 212ms
memory: 69740kb

input:

23
00000000010001001001010
00100010001101110000001
01000001000100110000000
00000011010001101100100
00000000010000010001000
00000000000000001001000
01010001000000000000001
00110010000000000000010
00000000011000100100000
10011000101000100000000
01000000110010101010000
01100000000000000000000
000000000...

output:

01111111110111110110111
10011111110111110110111
10011111110111110110111
11101111110110110110111
11110111110111110110111
11111011110111111111111
11111101110111110110111
11111110110111110110111
11111111010111110110111
11111111100110100110111
00000000000010000010100
11111111110011110110111
111111111111...

result:

ok 23 lines

Test #9:

score: 0
Accepted
time: 272ms
memory: 71536kb

input:

23
00001000001001000000000
00101100111110100000000
01001000100001011010000
00000000010000010010000
11100001100001000000010
01000010101010100011011
00000100000100100010000
00001000011000000010001
01101100000000011001001
01010001000010011000000
11000101000110001100000
01000010001000000000010
010001000...

output:

00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
000000000000...

result:

ok 23 lines

Test #10:

score: 0
Accepted
time: 369ms
memory: 75808kb

input:

23
00001011110010000000001
00000100000011000000100
00010011010100000000011
00100011011001010100100
10000101000110100000000
01001000001010001000100
10110000000110000010000
10111000001100010100010
10000000000010001000110
10110000001110100110001
00010101010100001000000
00101011011000100100011
110011101...

output:

00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
000000000000...

result:

ok 23 lines

Test #11:

score: 0
Accepted
time: 465ms
memory: 79332kb

input:

23
00100100001000000100001
00101110110000100100001
11000000000101001000100
00000000010000001111010
01000011010001011001010
11000000010100001001011
01001000001010101000100
00001000001010000000000
01000000000001100001011
01011100001101100000000
10000011010010100000010
00100100010000000001000
000000110...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #12:

score: 0
Accepted
time: 653ms
memory: 88856kb

input:

23
00000001011001011100100
00000001010000000010100
00000001010010100010000
00001000100111100000000
00010100011000010111001
00001000100001000010010
00000001111001100011000
11100010111100110001001
00010111010000101100110
11101011100000100100100
10001011000010100000010
00010001000001011101110
001100000...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #13:

score: 0
Accepted
time: 615ms
memory: 86876kb

input:

23
00100100001101000100000
00010111011000100000010
10000010010001111000010
01001011101001000100000
00010000010110000100111
11000000101000011101001
01110001100000010101100
01010010001001010100000
00010110001100010010001
01101000000011000111000
11010101100010010001101
10001000100010001110100
000010000...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #14:

score: 0
Accepted
time: 733ms
memory: 95416kb

input:

23
01001101001011010101100
10001010111100100001110
00000000010101000111100
00000000001010010100010
11000000100110000111000
10000010001000010101000
01000100100010001100101
10000000010001000110110
01001010000001111100000
01100001000001001101001
11010100000011001010111
01101000000000100100110
100110100...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #15:

score: 0
Accepted
time: 773ms
memory: 99136kb

input:

23
01100101000101001000001
10111000100000010110010
11011010011101000010010
01100010001111011011111
01100010011110001111100
10000000011000001011010
00111001001000101100111
10000010110110011000000
01000001001110010100100
00101101000100111100001
00111110100110011011010
10111001111010001010000
000110011...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #16:

score: 0
Accepted
time: 693ms
memory: 93260kb

input:

23
01111001001110001000101
10000000000100111111110
10010101000110100100101
10101000001010010101001
10010010011110101101111
00100000101100011000000
00001000011000010001101
10100000010000000000100
00000100010110001111100
00001011100101010110111
10011110000000010101101
11101100110010010100000
101110001...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #17:

score: 0
Accepted
time: 730ms
memory: 97376kb

input:

23
01010000000100001110001
10000110010001110010100
00011000101111001010110
10101111011100101100111
00110011111111111011000
01010011100001111011011
01011100001111000011101
00011100001110111010010
00101100011101001000011
01011000100000000000010
00111011100001001000111
10111011100000110100001
001010110...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #18:

score: 0
Accepted
time: 839ms
memory: 100200kb

input:

23
00100101011111000101011
00100001000110000111101
11010000011110010110011
00101101110110000101110
00010101111001110101110
10011001111101010011101
00000000110011000000100
11011100110111001110110
00011111000000100110010
10111111000111101010010
10101100000111111010100
11110101011010101010010
111100110...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #19:

score: 0
Accepted
time: 870ms
memory: 102560kb

input:

23
00100001100011011101011
00111011101101101011001
11001101100100001000111
01001010110101101000010
01110011001111000101111
00100011100000111101010
01011100000110101001100
11101100010110110011000
11110100010010000011010
00010001101011011011011
01001000010001001011111
01111011000010101011101
100010111...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #20:

score: 0
Accepted
time: 360ms
memory: 134156kb

input:

24
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
0000000000000000000000...

output:

000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
...

result:

ok 24 lines

Test #21:

score: 0
Accepted
time: 362ms
memory: 134244kb

input:

24
000000000000100000000000
000000000000000000001000
000000000000000001000000
000000100000000000000000
000000000000000000000001
000000000000000001000000
000100000000100100000000
000000000000000000000000
000000000000000000000000
000000000000010000000000
000000000000000000000000
0000000000000000010000...

output:

000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
...

result:

ok 24 lines

Test #22:

score: 0
Accepted
time: 368ms
memory: 134224kb

input:

24
000000000010000010000000
000000010100100000010010
000010010000000000000000
000000010000000001000000
001000000000001000000000
000000000100101000000000
000000000000000000000000
011100000001000000000000
000000000010000000000000
010001000000000010100001
100000001000000101000000
0000000100000000100100...

output:

000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
...

result:

ok 24 lines

Test #23:

score: 0
Accepted
time: 368ms
memory: 134296kb

input:

24
000001001001101000001101
000000000000011000100100
000000000000010000000000
000000010000000000000000
000000000000000000000000
100000010000000110000000
000000000001000000010000
000101000000000010000000
100000000001011100011100
000000000000000000100000
000000000000000010001000
1000001010001000000010...

output:

000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
...

result:

ok 24 lines

Test #24:

score: 0
Accepted
time: 489ms
memory: 137460kb

input:

24
011010010001001000000011
100000000000000111000001
100110000100100100010001
001011000100001000110000
101101000000000111000010
000110110000010000010000
000001000000000000000000
100001000001100001000001
000000000001000000110011
001100000000010000001000
000000000000000100000000
1000000110000010000000...

output:

000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000010000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000100000000000000000
000000000000000000000000
...

result:

ok 24 lines

Test #25:

score: 0
Accepted
time: 677ms
memory: 141576kb

input:

24
010001010000000000000100
101011011100001011001100
010101010010000100000000
001001101010000000110010
010000000000000000001010
111100000010001101000100
000100000000010000110000
111000000000000011000001
010100000010000000010100
010000000000000001000001
001101001001100110000001
0000000000100100001000...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111110111111
111111111110111111111111
...

result:

ok 24 lines

Test #26:

score: 0
Accepted
time: 1274ms
memory: 163788kb

input:

24
010001000001001010000001
100001001110101011001010
000000011000010000000100
000000010000100001110101
000000011001000001100010
110000000000000000011000
000000001000000100011010
001110001010000001110001
011010110000010000001001
010000000000100111100101
010000010000001000000000
1000100000000100101110...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #27:

score: 0
Accepted
time: 1146ms
memory: 161428kb

input:

24
010000000000000010000000
100000111000100110000011
000000111110010111000000
000001100001010000001100
000000001000000000110100
000100000100000101101111
011100010111010000110100
011000100010100000100010
011010000011001110000001
001001100010001001000010
001000111100000000100000
0001001010001100001000...

output:

011111111111111111111111
101111111111111101111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #28:

score: 0
Accepted
time: 1009ms
memory: 152644kb

input:

24
000100000000010010100000
000000001101000010011011
000000000011000000010000
100010100000100000010000
000100000010110101100001
000000111010100000100101
000101000110000011000000
000001001100101010000011
010001010000000010000101
010000110001011001010000
001011100000010010000011
0110000001000101100101...

output:

011111111111111111111111
101111111111111111011111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #29:

score: 0
Accepted
time: 1393ms
memory: 174872kb

input:

24
000000000010110010000001
001010001011101000000110
010001001110000000010000
000000100010000010011101
010001101010010011010100
001010000000011101000010
000110000100101011001111
000000001000110000100000
011010010110000000000000
001000101010001010000100
111110001100100010011101
0100000000001011100000...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #30:

score: -100
Time Limit Exceeded

input:

24
010001111000001000000110
100001111000000110010000
000011000101000101100100
000001111111000110100100
001000001010010000111000
111100100000000001110000
110101011101000000001101
110100101000001011000100
110110110011001000000000
001100100000000011011001
000110001000100101110111
0011001010000110110100...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result: