답안 #889109

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889109 2023-12-18T22:26:04 Z Maite_Morale Maze (JOI23_ho_t3) C++14
19 / 100
196 ms 31680 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define X first
#define Y second
#define MAX 2005
#define oo 1e18
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0);
using namespace std;
typedef long long ll;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>
#define ppp pair<pair<pll,pll>,pll>

ll m,k,n,pass[MAX][MAX];pll d[4]={{0,1},{0,-1},{1,0},{-1,0}};
pll s,e;
string a[MAX];
ppp inv(ppp h){
    h.F.F.F*=-1;h.F.F.S*=-1;
    h.F.S.F*=-1;h.F.S.S*=-1;
return h;
}
ll distra(){
    priority_queue<ppp> q;
    q.push(inv({{{0,k},{k,k}},s}));  
    while(!q.empty()){
        ppp u=inv(q.top());q.pop();
        if(pass[u.S.X][u.S.Y]!=-1)continue;
        if(u.S.X==e.X && u.S.Y==e.Y)return u.F.F.F;
      //  cout<<u.S.X<<" "<<u.S.Y<<" "<<u.F.F.F<<" "<<u.F.F.S<<" "<<u.F.S.F<<" "<<u.F.S.S<<"\n";
        pass[u.S.X][u.S.Y]=u.F.F.F;
        for(int i=0;i<4;i++){
            pll w1={u.S.X+d[i].F,u.S.Y+d[i].S};
            if(a[w1.X][w1.Y]=='*')continue;
            ppp w={u.F,w1};
            if(w.F.F.S==k){
                if(a[w1.X][w1.Y]=='.'){
                    q.push(inv(w));continue;
                }
              //  cout<<w1.X<<" "<<w1.Y<<"\n";
                w.F={{w.F.F.F+1,0},{0,0}};
            }
            w.F.S.F+=abs(d[i].F);
            w.F.S.S+=abs(d[i].S);
            w.F.F.S=max(w.F.S.F,w.F.S.S);
            q.push(inv(w));
        }
    }
return -1;
}
int main(){
    fast_in
    cin>>n>>m>>k>>s.X>>s.Y>>e.X>>e.Y;
    for(int i=0;i<=m+1;i++){
        a[0]+='*';a[n+1]='*';
    }
    for(int i=1;i<=n;i++){
        string asd;
        cin>>asd;
        a[i]+='*';
        a[i]+=asd;
        a[i]+='*';
        for(int j=0;j<=m+1;j++)pass[i][j]=-1;
    }
    cout<<distra();
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 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 532 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 532 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 30 ms 4968 KB Output is correct
20 Correct 8 ms 2936 KB Output is correct
21 Correct 21 ms 5036 KB Output is correct
22 Correct 36 ms 5388 KB Output is correct
23 Correct 33 ms 4952 KB Output is correct
24 Correct 17 ms 2908 KB Output is correct
25 Correct 5 ms 2904 KB Output is correct
26 Correct 4 ms 5148 KB Output is correct
27 Correct 3 ms 5036 KB Output is correct
28 Correct 18 ms 5208 KB Output is correct
29 Correct 91 ms 7460 KB Output is correct
30 Incorrect 13 ms 2904 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 1 ms 2396 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 1 ms 2396 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2808 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2576 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2404 KB Output is correct
12 Correct 1 ms 560 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 528 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2652 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 4 ms 2860 KB Output is correct
26 Correct 5 ms 3356 KB Output is correct
27 Correct 18 ms 4956 KB Output is correct
28 Correct 4 ms 4956 KB Output is correct
29 Correct 25 ms 5016 KB Output is correct
30 Correct 15 ms 4956 KB Output is correct
31 Correct 12 ms 2908 KB Output is correct
32 Correct 3 ms 5148 KB Output is correct
33 Correct 4 ms 5404 KB Output is correct
34 Correct 7 ms 5980 KB Output is correct
35 Correct 27 ms 7460 KB Output is correct
36 Correct 7 ms 7264 KB Output is correct
37 Correct 38 ms 7284 KB Output is correct
38 Correct 67 ms 7260 KB Output is correct
39 Correct 10 ms 12884 KB Output is correct
40 Incorrect 196 ms 31680 KB Output isn't correct
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 1 ms 2396 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 1 ms 2396 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2808 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2576 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 1 ms 2652 KB Output is correct
33 Correct 30 ms 4956 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 4 ms 2904 KB Output is correct
37 Correct 6 ms 2740 KB Output is correct
38 Correct 4 ms 3224 KB Output is correct
39 Correct 18 ms 4956 KB Output is correct
40 Correct 37 ms 5196 KB Output is correct
41 Correct 33 ms 4956 KB Output is correct
42 Correct 4 ms 4952 KB Output is correct
43 Correct 26 ms 5024 KB Output is correct
44 Correct 15 ms 4956 KB Output is correct
45 Correct 17 ms 2908 KB Output is correct
46 Correct 5 ms 3056 KB Output is correct
47 Incorrect 17 ms 2956 KB Output isn't correct
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 1 ms 2396 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 1 ms 2396 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2808 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2576 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 1 ms 2652 KB Output is correct
33 Correct 30 ms 4956 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 4 ms 2904 KB Output is correct
37 Correct 6 ms 2740 KB Output is correct
38 Correct 4 ms 3224 KB Output is correct
39 Correct 18 ms 4956 KB Output is correct
40 Correct 37 ms 5196 KB Output is correct
41 Correct 33 ms 4956 KB Output is correct
42 Correct 4 ms 4952 KB Output is correct
43 Correct 26 ms 5024 KB Output is correct
44 Correct 15 ms 4956 KB Output is correct
45 Correct 17 ms 2908 KB Output is correct
46 Correct 5 ms 3056 KB Output is correct
47 Incorrect 17 ms 2956 KB Output isn't correct
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 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 532 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 532 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 30 ms 4968 KB Output is correct
20 Correct 8 ms 2936 KB Output is correct
21 Correct 21 ms 5036 KB Output is correct
22 Correct 36 ms 5388 KB Output is correct
23 Correct 33 ms 4952 KB Output is correct
24 Correct 17 ms 2908 KB Output is correct
25 Correct 5 ms 2904 KB Output is correct
26 Correct 4 ms 5148 KB Output is correct
27 Correct 3 ms 5036 KB Output is correct
28 Correct 18 ms 5208 KB Output is correct
29 Correct 91 ms 7460 KB Output is correct
30 Incorrect 13 ms 2904 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 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 532 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 532 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 30 ms 4968 KB Output is correct
20 Correct 8 ms 2936 KB Output is correct
21 Correct 21 ms 5036 KB Output is correct
22 Correct 36 ms 5388 KB Output is correct
23 Correct 33 ms 4952 KB Output is correct
24 Correct 17 ms 2908 KB Output is correct
25 Correct 5 ms 2904 KB Output is correct
26 Correct 4 ms 5148 KB Output is correct
27 Correct 3 ms 5036 KB Output is correct
28 Correct 18 ms 5208 KB Output is correct
29 Correct 91 ms 7460 KB Output is correct
30 Incorrect 13 ms 2904 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 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 532 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 532 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 30 ms 4968 KB Output is correct
20 Correct 8 ms 2936 KB Output is correct
21 Correct 21 ms 5036 KB Output is correct
22 Correct 36 ms 5388 KB Output is correct
23 Correct 33 ms 4952 KB Output is correct
24 Correct 17 ms 2908 KB Output is correct
25 Correct 5 ms 2904 KB Output is correct
26 Correct 4 ms 5148 KB Output is correct
27 Correct 3 ms 5036 KB Output is correct
28 Correct 18 ms 5208 KB Output is correct
29 Correct 91 ms 7460 KB Output is correct
30 Incorrect 13 ms 2904 KB Output isn't correct
31 Halted 0 ms 0 KB -