QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#457085#8119. Pingvinfryan#70 ✓67ms21912kbC++201.4kb2024-06-29 01:49:132024-06-29 01:49:14

Judging History

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

  • [2024-06-29 01:49:14]
  • 评测
  • 测评结果:70
  • 用时:67ms
  • 内存:21912kb
  • [2024-06-29 01:49:13]
  • 提交

answer

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define int long long
const int mxn = 100;

int n, g[mxn+2][mxn+2][mxn+2], vis[mxn+2][mxn+2][mxn+2];

int sx, sy, sz, ex, ey, ez;

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cin >> n;
	cin >> sx >> sy >> sz >> ex >> ey >> ez;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				char f; cin >> f;
				g[j][k][i] = '1'-f;
			}
		}
	}
	queue<array<int,4>> bfs;
	bfs.push({sx,sy,sz,0});
	while (!bfs.empty()) {
		auto f = bfs.front(); bfs.pop();
		int x = f[0], y = f[1], z = f[2], d = f[3];
		if (vis[x][y][z]) continue;
		if (!g[x][y][z]) continue;
		vis[x][y][z] = 1;
		if (x == ex && y == ey && z == ez) {
			cout << d; return 0;
		}
		d++;
		bfs.push({x+1,y,z,d});
		bfs.push({x-1,y,z,d});
		bfs.push({x,y+1,z,d});
		bfs.push({x,y-1,z,d});
		bfs.push({x,y,z+1,d});
		bfs.push({x,y,z-1,d});
	}
	cout << -1;
	
	return 0;
}

詳細信息

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 1ms
memory: 5580kb

input:

2
1 2 1
1 2 2
10
10
10
10

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5608kb

input:

2
1 2 1
1 1 1
00
10
10
10

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5840kb

input:

2
1 2 1
2 1 2
10
00
10
00

output:

3

result:

ok single line: '3'

Test #4:

score: 0
Accepted
time: 1ms
memory: 5612kb

input:

2
1 1 1
2 1 2
00
01
10
00

output:

2

result:

ok single line: '2'

Test #5:

score: 0
Accepted
time: 1ms
memory: 5604kb

input:

2
2 2 1
2 2 1
01
10
11
11

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 1ms
memory: 5560kb

input:

2
2 1 1
1 1 2
11
01
01
11

output:

-1

result:

ok single line: '-1'

Test #7:

score: 0
Accepted
time: 1ms
memory: 5912kb

input:

2
1 2 1
2 1 1
10
01
11
11

output:

-1

result:

ok single line: '-1'

Subtask #2:

score: 16
Accepted

Test #8:

score: 16
Accepted
time: 1ms
memory: 5740kb

input:

5
4 1 1
5 5 4
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000
00000

output:

8

result:

ok single line: '8'

Test #9:

score: 0
Accepted
time: 1ms
memory: 7996kb

input:

10
1 3 1
7 2 2
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000...

output:

8

result:

ok single line: '8'

Test #10:

score: 0
Accepted
time: 1ms
memory: 8124kb

input:

20
3 16 1
15 16 10
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000...

output:

21

result:

ok single line: '21'

Test #11:

score: 0
Accepted
time: 4ms
memory: 12124kb

input:

50
47 4 1
25 32 26
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000...

output:

75

result:

ok single line: '75'

Test #12:

score: 0
Accepted
time: 19ms
memory: 18664kb

input:

100
50 69 1
54 44 33
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

61

result:

ok single line: '61'

Test #13:

score: 0
Accepted
time: 67ms
memory: 21912kb

input:

100
74 34 1
3 27 71
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

148

result:

ok single line: '148'

Test #14:

score: 0
Accepted
time: 34ms
memory: 20512kb

input:

100
73 19 1
29 73 4
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

101

result:

ok single line: '101'

Subtask #3:

score: 22
Accepted

Test #15:

score: 22
Accepted
time: 0ms
memory: 5636kb

input:

5
2 4 1
5 1 1
00101
00001
01000
10000
01000
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111

output:

-1

result:

ok single line: '-1'

Test #16:

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

input:

10
2 10 1
9 6 1
1000110000
0100100100
0101000100
0000101001
0110101001
0100000000
0000110000
1000000111
1000101000
0110000111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
111111111...

output:

11

result:

ok single line: '11'

Test #17:

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

input:

20
5 1 1
18 13 1
10100011010110100000
10011000010100000010
01100101100001010010
00001000010111110000
00000000001010001000
00011011000000101001
11000010111000100010
00100100010110010000
10101001001001000000
10010011000000100010
00010000100010001111
00110000011000001110
10001000000101010010
0001001011...

output:

31

result:

ok single line: '31'

Test #18:

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

input:

50
7 18 1
43 46 1
01000100000100111000000100101100000011010100010100
11000010110100010100101010010010010000000011101000
10100010001001101000000010011000000000000001000101
10101010000001000000000100100101010000000110010001
10010100000010000001100001100000101110100000000010
010101110000001110010100000...

output:

104

result:

ok single line: '104'

Test #19:

score: 0
Accepted
time: 7ms
memory: 15532kb

input:

100
15 96 1
14 33 1
0000000010111010011011000110100001000000000111101000011001110110010100011001010000101001010100100011
1000101011001000100100001001111100001011010010111000001000000111110110000100011110000001010101011011
010000100010000001000111100001010000100001000110110100000010101100011001100010...

output:

100

result:

ok single line: '100'

Test #20:

score: 0
Accepted
time: 10ms
memory: 15480kb

input:

100
24 60 1
56 52 1
0000100100000101000100000001100000010000001000010001000000011111110000001001010010101011010111001010
1001111011000010001000001100000001000000110000000000000010000010100010000100000000001000001001001100
001000000001000010110010001110010000001010010010110000001101110010100111110000...

output:

46

result:

ok single line: '46'

Test #21:

score: 0
Accepted
time: 10ms
memory: 15016kb

input:

100
70 39 1
92 22 1
0000000010100101000000000100000000001010000010110111001000100001110000110000100101000001011001010000
1000000000011100000000101010000110000000100101001100000000010111001100100001011001100111010000000000
100100100110101000000100110100110001000000011100001100011000000110100001000000...

output:

45

result:

ok single line: '45'

Test #22:

score: 0
Accepted
time: 8ms
memory: 19792kb

input:

100
22 86 1
83 28 1
1000000000101010001100000000000010011100001000100000001010000000101100111001000110000010010001111010
0000000100110000010111001010100111111000000111011100110001010000111101101000101100110100000110100010
001111000001101010000011001000100110010010000000101001100000001001100000110000...

output:

167

result:

ok single line: '167'

Test #23:

score: 0
Accepted
time: 7ms
memory: 18528kb

input:

100
12 46 1
86 16 1
0000000110000000000101001000000001010101110101110000001110110010001110000011000010001010110011001010
1001100011000110000100010100000001010111000100100100011010001000000000010100100011101101110000001100
000101001110101010000000000101010100010010010000010000001010001100000000010000...

output:

124

result:

ok single line: '124'

Subtask #4:

score: 25
Accepted

Test #24:

score: 25
Accepted
time: 0ms
memory: 5952kb

input:

5
2 3 1
4 2 5
00001
10011
10111
00000
00100
11010
11010
00110
11101
00100
01101
01001
11001
00111
00110
01111
11100
00000
10101
11100
01011
10001
01100
00100
10101

output:

7

result:

ok single line: '7'

Test #25:

score: 0
Accepted
time: 1ms
memory: 7832kb

input:

10
6 1 1
8 3 10
0001110110
1001010001
1010001011
1011101001
1101110011
0011000110
1000110101
0000011001
1010011011
0010101000
1010000101
0001011000
1010100011
0001100000
0111000010
0100011111
0000100000
1010001111
0110010000
1110000010
0001010011
0101101001
0111111001
1100110011
1010000110
111110111...

output:

23

result:

ok single line: '23'

Test #26:

score: 0
Accepted
time: 1ms
memory: 8116kb

input:

20
4 18 1
5 8 14
01100101110111111000
00000010011001101100
10010000110101111100
11000100000011101000
01100001001100100100
01010100011111100101
11110010001100111001
10101100111010010101
00011010001110000110
01001111110101101111
11101101100001110011
00010111010111001000
01001111010111111101
0011011110...

output:

30

result:

ok single line: '30'

Test #27:

score: 0
Accepted
time: 6ms
memory: 12420kb

input:

50
3 42 1
36 19 48
11000010101010011100010011100001111100000010111110
00011000010010011011111111111111110010000010011001
10110111000011011000011001010101011100110001101000
10000111011110000110100010010110111101110110100101
00111110100110011001101001001011001110110110111011
11101101010010000010101001...

output:

103

result:

ok single line: '103'

Test #28:

score: 0
Accepted
time: 11ms
memory: 14688kb

input:

100
31 67 1
37 59 23
1011101001001010010000001101110111001000010000010010100010101111101011111010000111101101010101101100
0111100100011010111011000010100101000010000110101110100110100001110101101111110100000100011101001011
00111100010011011100010111001010111101111011001100010010001011010110001001101...

output:

42

result:

ok single line: '42'

Test #29:

score: 0
Accepted
time: 13ms
memory: 15204kb

input:

100
37 5 1
69 20 14
0000100100100000010110110010001110101011010111100000110100111011101010001111111111101010011110000011
1101011100011110010001000010010010001000111111110000110010011101110110011110110101011011110110101100
011001101010111011101001110010000100010111101111011100101000110010010001111001...

output:

64

result:

ok single line: '64'

Test #30:

score: 0
Accepted
time: 31ms
memory: 19160kb

input:

100
95 69 1
11 72 6
1110010001100010100001100111001111010010011011101000110000100100111000000000100101100101111100000010
1101100100000100110110011000010110000101010000101111100011000011110110111100101011011000011001100110
001000111111001111000101101101100111011100000000011110000001100001011101001111...

output:

124

result:

ok single line: '124'

Test #31:

score: 0
Accepted
time: 9ms
memory: 13436kb

input:

100
28 20 1
85 37 33
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

-1

result:

ok single line: '-1'

Test #32:

score: 0
Accepted
time: 11ms
memory: 12220kb

input:

100
80 10 1
15 82 18
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

-1

result:

ok single line: '-1'

Extra Test:

score: 0
Extra Test Passed