답안 #736276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
736276 2023-05-05T11:43:36 Z Cookie Maze (JOI23_ho_t3) C++14
0 / 100
2000 ms 18944 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("WINTER.inp");
ofstream fout("WINTER.out");

#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
const int x[4] = {1, -1, 0, 0};
const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 7;
const int mxn = 5e5, mxm = 1e5, sq = 400;
const int base = (1 << 18);
const ll inf = 1e9;
const ld pre = 1e-6;
int r, c, n, sti, stj, eni, enj;
vt<vt<char>>a;
vt<vt<int>>d;
bool inside(int i, int j){
    return(i >= 1 && j >= 1 && i <= r && j <= c);
}
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> r >> c >> n;
    a.resize(r + 1, vt<char>(c + 1));
    d.resize(r + 1, vt<int>(c + 1));
    cin >> sti >> stj >> eni >> enj;
    forr(i, 1, r + 1){
        forr(j, 1, c + 1){
            cin >> a[i][j]; d[i][j] = 1e9;
        }
    }
    deque<pair<int, int>>dq; dq.pb({sti, stj});
    d[sti][stj] = 0;
    while(!dq.empty()){
        auto [i, j] = dq.front(); dq.pop_front();
        if(d[i][j] > 10)continue;
        if(a[i][j] == '.'){
        for(int t = 0; t < 4; t++){
            int nwi = i + x[t], nwj = j + y[t];
            if(inside(nwi, nwj)){
                if(d[nwi][nwj] > d[i][j]){
                    d[nwi][nwj] = d[i][j];
                    dq.push_front({nwi, nwj});
                }
            }
        }
        }
        for(auto ii: {i - n, i + n}){
            for(int jj = j - n + 1; jj <= j + n - 1; jj++){
                if(inside(ii, jj)){
                    if(d[ii][jj] > d[i][j] + 1){
                        d[ii][jj] = d[i][j] + 1;
                        dq.push_back({ii, jj});
                    }
                }
            }
        }
        for(auto jj : {j - n, j + n}){
            for(int ii = i - n + 1; ii <= i + n - 1; ii++){
                if(inside(ii, jj)){
                    if(d[ii][jj] > d[i][j] + 1){
                        d[ii][jj] = d[i][j] + 1;
                        dq.push_back({ii, jj});
                    }
                }
            }
        }
    }
    int ans = 1e9;
    for(int i = eni - n + 1; i <= eni + n - 1; i++){
        for(int j = enj - n + 1; j  <= enj + n - 1; j++){
            if(inside(i, j)){
                
                ans = min(ans, d[i][j] + 1);
            }
        }
    }
    ans = min(ans, d[eni][enj]);
    cout << ans;
    return(0);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:46:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   46 |         auto [i, j] = dq.front(); dq.pop_front();
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 13 ms 1164 KB Output is correct
27 Correct 4 ms 768 KB Output is correct
28 Correct 164 ms 848 KB Output is correct
29 Correct 2 ms 596 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 37 ms 736 KB Output is correct
32 Correct 5 ms 724 KB Output is correct
33 Correct 2 ms 596 KB Output is correct
34 Correct 209 ms 2148 KB Output is correct
35 Correct 9 ms 1748 KB Output is correct
36 Correct 655 ms 1784 KB Output is correct
37 Correct 4 ms 1116 KB Output is correct
38 Correct 4 ms 1108 KB Output is correct
39 Correct 380 ms 6884 KB Output is correct
40 Execution timed out 2052 ms 18944 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -