Submission #1065017

# Submission time Handle Problem Language Result Execution time Memory
1065017 2024-08-18T21:21:10 Z Dennis_Jason Maze (JOI23_ho_t3) C++14
8 / 100
91 ms 15184 KB
#include <bitset>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#define pb push_back
#define MOD 1000000007
#define NMAX 6000001
#define nl '\n'
#define INF 1000000007
#define pii1 pair<int, pair<int,int>>  (1,(1,2));
#define pii pair<int,int>
#define tpl tuple<int,int,int>
using namespace std;
ifstream fin("data.in");
ofstream fout("data.out");
/*
    ====================DEMONSTRATION======================

        n=2
        1....#####..##
        ....##########
        ####..........
        ##########....
        ##########....
        1....####....#
    =========================END===========================

 */
int r,c,n;
int x,y,a,b,node_s,node_f;
int di[]={1,-1,0,0};
int dj[]={0,0,1,-1};
bool inmat(int i,int j)
{
    return i>=1 && i<=r && j>=1 && j<=c;
}
const int R=x,L=y;
void bfs(int** mat)
{
    deque<tpl>dq;
    bool vis[r+1][c+1];
    memset(vis,0,sizeof(vis));
    vis[x][y]=1;
    int ans=INF;
    dq.push_front({x,y,0});
    while(!dq.empty())
    {
        auto[i,j,cost]=dq.front();
        dq.pop_front();
        if(i==a && j==b)
            ans=min(ans,cost);
        for(int d=0;d<4;++d)
        {
            int inou=di[d]+i;
            int jnou=dj[d]+j;
            if(inmat(inou,jnou) && !vis[inou][jnou])
            {
                if(mat[inou][jnou]==0)
                {
                    dq.push_front({inou,jnou,cost});
                }
                else
                {
                    dq.push_back({inou,jnou,cost+1});
                }
                vis[inou][jnou]=1;
            }
        }
    }

    cout<<ans;

}
signed main() {


    cin>>r>>c>>n;
    int **mat= new int*[r+1];
    for(int i=1;i<=r;++i)
        mat[i]=new int[c+1];
    cin>>x>>y;
    cin>>a>>b;
    for(int i=1;i<=r;++i)
    {
        for(int j=1;j<=c;++j)
        {
            char x;
            cin>>x;
            if(x=='.')
                mat[i][j]=0;
            else
                mat[i][j]=1;
        }
    }

    bfs(mat);


    return 0;
}

Compilation message

Main.cpp: In function 'void bfs(int**)':
Main.cpp:65:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   65 |         auto[i,j,cost]=dq.front();
      |             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 3 ms 736 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 3 ms 916 KB Output is correct
22 Correct 4 ms 736 KB Output is correct
23 Correct 3 ms 600 KB Output is correct
24 Correct 3 ms 856 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 4 ms 860 KB Output is correct
27 Correct 4 ms 600 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 8 ms 1332 KB Output is correct
30 Correct 4 ms 604 KB Output is correct
31 Correct 9 ms 2140 KB Output is correct
32 Correct 13 ms 1116 KB Output is correct
33 Correct 10 ms 1116 KB Output is correct
34 Correct 6 ms 1368 KB Output is correct
35 Correct 6 ms 1480 KB Output is correct
36 Correct 9 ms 1372 KB Output is correct
37 Correct 9 ms 1372 KB Output is correct
38 Correct 7 ms 1116 KB Output is correct
39 Correct 73 ms 9268 KB Output is correct
40 Correct 10 ms 1372 KB Output is correct
41 Correct 8 ms 1628 KB Output is correct
42 Correct 11 ms 1628 KB Output is correct
43 Correct 12 ms 1884 KB Output is correct
44 Correct 41 ms 4876 KB Output is correct
45 Correct 39 ms 5152 KB Output is correct
46 Correct 65 ms 15184 KB Output is correct
47 Correct 91 ms 9300 KB Output is correct
48 Correct 83 ms 9032 KB Output is correct
49 Correct 58 ms 10684 KB Output is correct
50 Correct 62 ms 10576 KB Output is correct
51 Correct 91 ms 9552 KB Output is correct
52 Correct 87 ms 9268 KB Output is correct
53 Correct 67 ms 9300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 3 ms 736 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 3 ms 916 KB Output is correct
22 Correct 4 ms 736 KB Output is correct
23 Correct 3 ms 600 KB Output is correct
24 Correct 3 ms 856 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 4 ms 860 KB Output is correct
27 Correct 4 ms 600 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 8 ms 1332 KB Output is correct
30 Correct 4 ms 604 KB Output is correct
31 Correct 9 ms 2140 KB Output is correct
32 Correct 13 ms 1116 KB Output is correct
33 Correct 10 ms 1116 KB Output is correct
34 Correct 6 ms 1368 KB Output is correct
35 Correct 6 ms 1480 KB Output is correct
36 Correct 9 ms 1372 KB Output is correct
37 Correct 9 ms 1372 KB Output is correct
38 Correct 7 ms 1116 KB Output is correct
39 Correct 73 ms 9268 KB Output is correct
40 Correct 10 ms 1372 KB Output is correct
41 Correct 8 ms 1628 KB Output is correct
42 Correct 11 ms 1628 KB Output is correct
43 Correct 12 ms 1884 KB Output is correct
44 Correct 41 ms 4876 KB Output is correct
45 Correct 39 ms 5152 KB Output is correct
46 Correct 65 ms 15184 KB Output is correct
47 Correct 91 ms 9300 KB Output is correct
48 Correct 83 ms 9032 KB Output is correct
49 Correct 58 ms 10684 KB Output is correct
50 Correct 62 ms 10576 KB Output is correct
51 Correct 91 ms 9552 KB Output is correct
52 Correct 87 ms 9268 KB Output is correct
53 Correct 67 ms 9300 KB Output is correct
54 Incorrect 1 ms 344 KB Output isn't correct
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 3 ms 736 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 3 ms 916 KB Output is correct
22 Correct 4 ms 736 KB Output is correct
23 Correct 3 ms 600 KB Output is correct
24 Correct 3 ms 856 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 4 ms 860 KB Output is correct
27 Correct 4 ms 600 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 8 ms 1332 KB Output is correct
30 Correct 4 ms 604 KB Output is correct
31 Correct 9 ms 2140 KB Output is correct
32 Correct 13 ms 1116 KB Output is correct
33 Correct 10 ms 1116 KB Output is correct
34 Correct 6 ms 1368 KB Output is correct
35 Correct 6 ms 1480 KB Output is correct
36 Correct 9 ms 1372 KB Output is correct
37 Correct 9 ms 1372 KB Output is correct
38 Correct 7 ms 1116 KB Output is correct
39 Correct 73 ms 9268 KB Output is correct
40 Correct 10 ms 1372 KB Output is correct
41 Correct 8 ms 1628 KB Output is correct
42 Correct 11 ms 1628 KB Output is correct
43 Correct 12 ms 1884 KB Output is correct
44 Correct 41 ms 4876 KB Output is correct
45 Correct 39 ms 5152 KB Output is correct
46 Correct 65 ms 15184 KB Output is correct
47 Correct 91 ms 9300 KB Output is correct
48 Correct 83 ms 9032 KB Output is correct
49 Correct 58 ms 10684 KB Output is correct
50 Correct 62 ms 10576 KB Output is correct
51 Correct 91 ms 9552 KB Output is correct
52 Correct 87 ms 9268 KB Output is correct
53 Correct 67 ms 9300 KB Output is correct
54 Incorrect 1 ms 344 KB Output isn't correct
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 3 ms 736 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 3 ms 916 KB Output is correct
22 Correct 4 ms 736 KB Output is correct
23 Correct 3 ms 600 KB Output is correct
24 Correct 3 ms 856 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 4 ms 860 KB Output is correct
27 Correct 4 ms 600 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 8 ms 1332 KB Output is correct
30 Correct 4 ms 604 KB Output is correct
31 Correct 9 ms 2140 KB Output is correct
32 Correct 13 ms 1116 KB Output is correct
33 Correct 10 ms 1116 KB Output is correct
34 Correct 6 ms 1368 KB Output is correct
35 Correct 6 ms 1480 KB Output is correct
36 Correct 9 ms 1372 KB Output is correct
37 Correct 9 ms 1372 KB Output is correct
38 Correct 7 ms 1116 KB Output is correct
39 Correct 73 ms 9268 KB Output is correct
40 Correct 10 ms 1372 KB Output is correct
41 Correct 8 ms 1628 KB Output is correct
42 Correct 11 ms 1628 KB Output is correct
43 Correct 12 ms 1884 KB Output is correct
44 Correct 41 ms 4876 KB Output is correct
45 Correct 39 ms 5152 KB Output is correct
46 Correct 65 ms 15184 KB Output is correct
47 Correct 91 ms 9300 KB Output is correct
48 Correct 83 ms 9032 KB Output is correct
49 Correct 58 ms 10684 KB Output is correct
50 Correct 62 ms 10576 KB Output is correct
51 Correct 91 ms 9552 KB Output is correct
52 Correct 87 ms 9268 KB Output is correct
53 Correct 67 ms 9300 KB Output is correct
54 Incorrect 1 ms 344 KB Output isn't correct
55 Halted 0 ms 0 KB -