QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#865333 | #8119. Pingvin | Unforgettablepl# | 16 | 35ms | 6016kb | C++20 | 1.2kb | 2025-01-21 16:48:44 | 2025-01-21 16:48:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector grid(n+1,vector(n+1,vector(n+1,false)));
vector visited(n+1,vector(n+1,vector(n+1,false)));
int xs,ys,zs,xe,ye,ze;
cin >> xs >> ys >> zs >> xe >> ye >> ze;
for(int k=1;k<=n;k++){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
char a;cin>>a;
if(a=='1')grid[i][j][k]=true;
}
}
}
queue<pair<int,tuple<int,int,int>>> pq;
pq.push({0ll,{xs,ys,zs}});
while(!pq.empty()){
auto [dist,pos] = pq.front();pq.pop();
auto [x,y,z] = pos;
if(visited[x][y][z])continue;
visited[x][y][z]=true;
if(x==xe and y==ye and z==ze){
cout << dist << '\n';
return 0;
}
if(x!=1 and !visited[x-1][y][z])pq.push({dist+1,{x-1,y,z}});
if(x!=n and !visited[x+1][y][z])pq.push({dist+1,{x+1,y,z}});
if(y!=1 and !visited[x][y-1][z])pq.push({dist+1,{x,y-1,z}});
if(y!=n and !visited[x][y+1][z])pq.push({dist+1,{x,y+1,z}});
if(z!=1 and !visited[x][y][z-1])pq.push({dist+1,{x,y,z-1}});
if(z!=n and !visited[x][y][z+1])pq.push({dist+1,{x,y,z+1}});
}
cout << "-1\n";
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 0ms
memory: 3712kb
input:
2 1 2 1 1 2 2 10 10 10 10
output:
1
result:
ok single line: '1'
Test #2:
score: 7
Accepted
time: 1ms
memory: 3584kb
input:
2 1 2 1 1 1 1 00 10 10 10
output:
1
result:
ok single line: '1'
Test #3:
score: 7
Accepted
time: 0ms
memory: 3712kb
input:
2 1 2 1 2 1 2 10 00 10 00
output:
3
result:
ok single line: '3'
Test #4:
score: 7
Accepted
time: 0ms
memory: 3584kb
input:
2 1 1 1 2 1 2 00 01 10 00
output:
2
result:
ok single line: '2'
Test #5:
score: 7
Accepted
time: 1ms
memory: 3584kb
input:
2 2 2 1 2 2 1 01 10 11 11
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
2 2 1 1 1 1 2 11 01 01 11
output:
2
result:
wrong answer 1st lines differ - expected: '-1', found: '2'
Subtask #2:
score: 16
Accepted
Test #8:
score: 16
Accepted
time: 1ms
memory: 3712kb
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: 16
Accepted
time: 0ms
memory: 3712kb
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: 16
Accepted
time: 1ms
memory: 3840kb
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: 16
Accepted
time: 4ms
memory: 4352kb
input:
50 47 4 1 25 32 26 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000...
output:
75
result:
ok single line: '75'
Test #12:
score: 16
Accepted
time: 14ms
memory: 5760kb
input:
100 50 69 1 54 44 33 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
61
result:
ok single line: '61'
Test #13:
score: 16
Accepted
time: 35ms
memory: 5988kb
input:
100 74 34 1 3 27 71 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
148
result:
ok single line: '148'
Test #14:
score: 16
Accepted
time: 23ms
memory: 6016kb
input:
100 73 19 1 29 73 4 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
101
result:
ok single line: '101'
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 1ms
memory: 3712kb
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:
6
result:
wrong answer 1st lines differ - expected: '-1', found: '6'
Subtask #4:
score: 0
Wrong Answer
Test #24:
score: 25
Accepted
time: 1ms
memory: 3712kb
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
Wrong Answer
time: 0ms
memory: 3712kb
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:
13
result:
wrong answer 1st lines differ - expected: '23', found: '13'