QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#478412#5514. Mazesnpmrnhlol16 354ms456664kbC++143.0kb2024-07-14 22:31:402024-07-14 22:31:41

Judging History

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

  • [2024-07-14 22:31:41]
  • 评测
  • 测评结果:16
  • 用时:354ms
  • 内存:456664kb
  • [2024-07-14 22:31:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 6e6;
const int inf = 2e9;
vector <char> v[N + 2];
vector <vector<bool>> vis[N + 2];
int k,n,m,sx,sy,ex,ey;
array<int,2> q[N + 5];
array<int,3> q2[N + 5];
array<int,3> q3[N + 5];
int d[8][2] = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int ans = inf;
    cin>>n>>m>>k;
    cin>>sx>>sy>>ex>>ey;
    for(int i = 0;i < n + 2;i++){
        v[i].assign(m + 2,0);
        vis[i].assign(m + 2,vector<bool>(3,0));
        v[i][0] = 2;
        v[i][m + 1] = 2;
    }
    for(int i = 0;i < m + 2;i++){
        v[0][i] = 2;
        v[n + 1][i] = 2;
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            char ch;
            cin>>ch;
            if(ch == '.'){
                v[i + 1][j + 1] = 0;
            }else{
                v[i + 1][j + 1] = 1;
            }
        }
    }
    vis[sx][sy][0] = 1;
    int pt = 0,sz = 0;
    int pt2 = 0,sz2 = 0;
    int pt3 = 0,sz3 = 0;
    q[sz++] = {sx,sy};
    for(int i = 0;i <= n + m;i++){
        while(pt < sz){
            auto x = q[pt];pt++;
            //cout<<x[0]<<' '<<x[1]<<' '<<i<<'\n';
            if(x[0] == ex && x[1] == ey){
                ans = i;
            }
            ///bfs
            if(!vis[x[0]][x[1]][1]){
                q2[sz2++] = {x[0],x[1],0};
            }
            for(int j = 0;j < 4;j++){
                int nx = x[0] + d[j][0];
                int ny = x[1] + d[j][1];
                if(!vis[nx][ny][0] && v[nx][ny] == 0){
                    vis[nx][ny][0] = 1;
                    q[sz++] = {nx,ny};
                }
            }
        }
        while(pt2 < sz2){
            auto x = q2[pt2];
            pt2++;
            if(!vis[x[0]][x[1]][2]){
                q3[sz3++] = {x[0],x[1],(x[2] == k?1:0)};
                vis[x[0]][x[1]][2] = 1;
            }
            if(x[2] != k){
                for(int j = 0;j < 2;j++){
                    int nx = x[0] + d[j][0];
                    int ny = x[1] + d[j][1];
                    if(!vis[nx][ny][1] && v[nx][ny] != 2){
                        vis[nx][ny][1] = 1;
                        q2[sz2++] = {nx,ny,x[2] + 1};
                    }
                }
            }
        }
        while(pt3 < sz3){
            auto x = q3[pt3];
            pt3++;
            if(!vis[x[0]][x[1]][0]){
                q[sz++] = {x[0],x[1]};
                vis[x[0]][x[1]][0] = 1;
            }
            if(x[2] != k){
                for(int j = 2;j < 4;j++){
                    int nx = x[0] + d[j][0];
                    int ny = x[1] + d[j][1];
                    if(!vis[nx][ny][2] && v[nx][ny] != 2){
                        vis[nx][ny][2] = 1;
                        q3[sz3++] = {nx,ny,x[2] + 1};
                    }
                }
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 39ms
memory: 284764kb

input:

31 32 1
25 22
5 3
################################
################################
.###############################
.###############################
##..###############.############
###.###############.############
#####.##########################
###.#.##########################
###.##############...

output:

2000000000

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #52:

score: 19
Accepted
time: 47ms
memory: 285096kb

input:

3 6 2
2 1
3 3
...###
..##..
#..###

output:

0

result:

ok single line: '0'

Test #53:

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

input:

4 24 4
3 4
3 3
..#...##.#...###...###.#
.##.#..##.##.##..#.####.
#.......#.#.#...#.#####.
######....######.#...#.#

output:

0

result:

ok single line: '0'

Test #54:

score: -19
Wrong Answer
time: 23ms
memory: 284812kb

input:

2 136 2
1 133
2 45
#############################################.##################.#.#######.##############.#################.##############.##.######.###
####.########.###############.####.###..####.#.###.#################.##..##############.###.############################################

output:

2000000000

result:

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

Subtask #3:

score: 16
Accepted

Test #64:

score: 16
Accepted
time: 32ms
memory: 285096kb

input:

35 60 20
3 60
2 44
.#....##.#.###..##.#.#....#.....#..#..#.##.#..#....###.####.
#.#......#.####..####...#...#......#........####....##.#.###
.#..#.....#.####..#.##..#.#.#...#.##..#.#..#######....#..##.
.#.#...##..#.##.......#......##......####...##.##..##.#....#
#...#.......#..#..#...#.#####.##.###....

output:

1

result:

ok single line: '1'

Test #65:

score: 0
Accepted
time: 40ms
memory: 289084kb

input:

63 602 3
10 463
3 402
#.#.#..#..######.#.##.##.#########.###.##.##..#..####.#...#########..###..####.######.###.##.#.....############.####.########.#.########.##.######.###..#####.###..##.#..#..##..##.###..##.###.#######...#.##.##.#.#.##...##...####.###.##.#.#.....#####.##.#..#.##..#...######.#####....

output:

9

result:

ok single line: '9'

Test #66:

score: 0
Accepted
time: 36ms
memory: 291276kb

input:

45 1194 5
4 632
37 206
...#..#............#..........#..##....##......#...##..#..#.............#...#...........##....#.........#.#.##..........#......#..........#.....#...........#........#.#.................#................#..........##.......................#.....#..........#........#........#......

output:

0

result:

ok single line: '0'

Test #67:

score: 0
Accepted
time: 39ms
memory: 291744kb

input:

244 245 244
28 168
222 200
...#...................................................................................................................................................................#..............................................................#..............
..............................

output:

0

result:

ok single line: '0'

Test #68:

score: 0
Accepted
time: 36ms
memory: 291968kb

input:

244 245 244
175 140
70 11
##.##....###.###..######..###.#.#####.##..#.#####.#.###.###.....#....###.#####.##..#.###.####.#..##.####...#.#####.###.##..#######.##.##...#..####.#...#####.##.###.#....##..####.###.#.#####..#.#.##.###.#..#.##.####..#.#.#...#######.######.##.#..
#..#..##.####.###.###..........

output:

1

result:

ok single line: '1'

Test #69:

score: 0
Accepted
time: 44ms
memory: 291776kb

input:

244 245 244
241 52
100 202
#######.###################################################################################################################################################################.#########################################################################
###########################...

output:

1

result:

ok single line: '1'

Test #70:

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

input:

62 967 62
41 1
29 386
####.######.####.#####...##.##..##.####..######.##...######....#.#..#...#.#.###.##.###...######..#.#.####.###.##.###.#...###..##..####.####.#.#...###..#.#..#..###.....#####.##..##.####..##......#.####.##.#...##..###.#....#..##.###.#..#####.#..#.#.#.##..#..#.#..##.##.####...#.#....

output:

6

result:

ok single line: '6'

Test #71:

score: 0
Accepted
time: 52ms
memory: 298568kb

input:

202 595 58
71 324
182 516
..#.###....#.##......#............#...#.###....................#....#....#...#.##.........#.....#....#.#.......###.#........#####..#.......###......#......#.......#...##..........#.#.....#.#.................#.#...#..#.#.......#.#.##...#.#..#......#.....#.......#.#..#..#.......

output:

0

result:

ok single line: '0'

Test #72:

score: 0
Accepted
time: 48ms
memory: 302080kb

input:

387 387 387
100 184
358 250
................#...........................................................................................................................................#......................................................................................................................

output:

0

result:

ok single line: '0'

Test #73:

score: 0
Accepted
time: 59ms
memory: 302060kb

input:

387 387 387
133 20
329 125
#..##.##..###.##.##..######..#####.#.#####..#####.####.#....##.#.#.#.#.##.##..##.###....#.#..#.#.##...###########..##..#.##..##.######.##.#.#####.###.##.#....#..##.##.##.#####..#.##.##.####..#.###.##.##.#.#....###...#.#.###.##..####..##.##.#.#.#.#.###....#.###.#.#..#.###.#...

output:

1

result:

ok single line: '1'

Test #74:

score: 0
Accepted
time: 47ms
memory: 302292kb

input:

387 387 387
201 41
238 340
###########################################################################.#####################################################################################################################################################################################################...

output:

1

result:

ok single line: '1'

Test #75:

score: 0
Accepted
time: 106ms
memory: 333156kb

input:

601 723 26
258 272
578 200
#.#.....#..#.##.##.##.......#.......#...#..#.....##...##.##..###.....#.....#.#.#....###...#.#....#...##..#..#.####...#..#..#.......#..##.....###...#.#.#....#....####..###.#.##..##....##.....##.#..#.##.#.#....#......#...##.....##.......#..#.#...#..#..##...#...#....####.##.#...

output:

0

result:

ok single line: '0'

Test #76:

score: 0
Accepted
time: 321ms
memory: 427416kb

input:

103 12319 67
96 7020
42 1423
..##.###......#...#...#.........#........#....#..#...##.......#..###......###...#...##..#.##.##......##..#....#..............#.#......#.#...#...#..#..##.#..#....#.........###...#.....#..#..###...#.......#..#...##...#..####.##.#.##..##...#..#..####...#.......#.#....#..#.#...

output:

0

result:

ok single line: '0'

Test #77:

score: 0
Accepted
time: 284ms
memory: 456380kb

input:

1224 1225 1224
582 110
326 1104
..................................................................................#...........................................................................................................................................................#................................

output:

0

result:

ok single line: '0'

Test #78:

score: 0
Accepted
time: 334ms
memory: 456664kb

input:

1224 1225 1224
1024 851
437 463
##..#.###.####..##..#...#.#...##.#.#.########.#.#####..##..##.###..##..##..##.#...#.##.##.#####..###########.#.##...#.###########.####..####...#......##...###..#.#.####.#####.#.####.####.##..#.######..#.#.##.#.#.#.####....#...###.##...#..#..#####..#.#####.#...##.##......

output:

1

result:

ok single line: '1'

Test #79:

score: 0
Accepted
time: 280ms
memory: 456472kb

input:

1224 1225 1224
188 85
758 1157
#####.##.########################################################################################################################################################.###############################################################.###########################################...

output:

1

result:

ok single line: '1'

Test #80:

score: 0
Accepted
time: 353ms
memory: 451992kb

input:

72 20833 72
41 567
6 17116
##.....##.##..#..###....###.#..##..#.#...#......#.#..###.#..#.#.#..##..#.##.......#...#.###..##.#.#..#....#....##..........#..#...##...#........#..#.#.##.###.#.###....###.#....#.#...#....#.##..#.#.##.#######.#...##....#.#.......##..#..#...##.##.........#..#....#..###.##......

output:

0

result:

ok single line: '0'

Test #81:

score: 0
Accepted
time: 354ms
memory: 450984kb

input:

114 13157 114
100 43
54 9728
.....#.....##.##....##.#..###.###.#..#.#...#....#.##.....#..#.#.###................###...#..#..#.##.#...#..#.##........#...#.#..##...#..###..##.#.....#.#.....#.....##.....#.##..#.#....#..#.##..#..##..#.###.##...#.#.#.#..##...#...#...#.##.##.#.#....#..#.#.........#....##....

output:

0

result:

ok single line: '0'

Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%

Subtask #8:

score: 0
Skipped

Dependency #7:

0%