답안 #806693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
806693 2023-08-04T08:57:41 Z Arturgo Maze (JOI23_ho_t3) C++14
8 / 100
50 ms 12128 KB
#include <bits/stdc++.h>
using namespace std;

pair<int, int> operator + (const pair<int, int>& a, const pair<int, int>& b) {
    return {a.first + b.first, a.second + b.second};
}

int nbLigs, nbCols, cote;
int lDeb, cDeb, lFin, cFin;
vector<string> terrain;

bool estDans(pair<int, int> p) {
   return p.first >= 0 && p.second >= 0 
   && p.first < nbLigs && p.second < nbCols;
}

vector<pair<int, int>> aExplorer;
vector<vector<bool>> explorees, dansAExplorer;

pair<int, int> deps[4] = {
    {0, 1},
    {1, 0},
    {0, -1},
    {-1, 0}
};

int curPasse = 0;
vector<vector<int>> derPasse;

vector<pair<int, int>> expand(vector<pair<int, int>> cells, 
    pair<int, int> dir) {
    vector<pair<int, int>> nouvCells;
    
    for(pair<int, int> cell : cells) {
        pair<int, int> nxt = cell + dir;
        
        if(estDans(nxt)
        && !dansAExplorer[nxt.first][nxt.second]) {
            aExplorer.push_back(nxt);
            terrain[nxt.first][nxt.second] = '.';
            dansAExplorer[nxt.first][nxt.second] = true;
            
            nouvCells.push_back(nxt);
        }
    }
    
    return nouvCells;
}

int main() {
    ios_base::sync_with_stdio(false);

    cin >> nbLigs >> nbCols >> cote;
    cin >> lDeb >> cDeb >> lFin >> cFin;
    lDeb--; cDeb--; lFin--; cFin--;
    
    for(int iLig = 0;iLig < nbLigs;iLig++) {
        string lig;
        cin >> lig;
        terrain.push_back(lig);
    }
    
    explorees = vector<vector<bool>>(
        nbLigs, vector<bool>(nbCols, false)
    );
    
    dansAExplorer = vector<vector<bool>>(
        nbLigs, vector<bool>(nbCols, false)
    );
    
    aExplorer.push_back({lDeb, cDeb});
    
    int dist = 0;
    while(true) {
        vector<pair<int, int>> murs;
        while(!aExplorer.empty()) {
            pair<int, int> cell = aExplorer.back();
            aExplorer.pop_back();
            
            if(terrain[cell.first][cell.second] == '#') {
                murs.push_back({cell.first, cell.second});
            }
            else {
                explorees[cell.first][cell.second] = true;
                
                for(pair<int, int> dep : deps) {
                    pair<int, int> nxt = cell + dep;
                    if(estDans(nxt) && !dansAExplorer[nxt.first][nxt.second]) {
                        dansAExplorer[nxt.first][nxt.second] = true;
                        aExplorer.push_back(nxt);
                    }
                }
            }
        }
        
        if(explorees[lFin][cFin]) {
            break;
        }
        dist++;
        
        // expand rectangles
        
        vector<pair<int, int>> cells = murs;
        for(pair<int, int> cell : cells) {
            aExplorer.push_back(cell);
            terrain[cell.first][cell.second] = '.';
            dansAExplorer[cell.first][cell.second] = true;
        }
        
        for(int iFois = 0;iFois < cote - 1;iFois++) {
            cells = expand(cells, deps[0]);
            cells = expand(cells, deps[2]);
        }
        
         for(int iFois = 0;iFois < cote - 1;iFois++) {
            cells = expand(cells, deps[1]);
            cells = expand(cells, deps[3]);
        }
    }
    
    cout << dist << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 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 1 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 320 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 1 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 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 368 KB Output is correct
21 Correct 2 ms 780 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 3 ms 460 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 3 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 524 KB Output is correct
29 Correct 5 ms 724 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 4 ms 1872 KB Output is correct
32 Correct 5 ms 724 KB Output is correct
33 Correct 5 ms 716 KB Output is correct
34 Correct 3 ms 864 KB Output is correct
35 Correct 6 ms 856 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 4 ms 852 KB Output is correct
38 Correct 1 ms 772 KB Output is correct
39 Correct 50 ms 3904 KB Output is correct
40 Correct 2 ms 724 KB Output is correct
41 Correct 3 ms 992 KB Output is correct
42 Correct 8 ms 852 KB Output is correct
43 Correct 6 ms 936 KB Output is correct
44 Correct 8 ms 2008 KB Output is correct
45 Correct 14 ms 2232 KB Output is correct
46 Correct 35 ms 12128 KB Output is correct
47 Correct 43 ms 4076 KB Output is correct
48 Correct 37 ms 3796 KB Output is correct
49 Correct 19 ms 4800 KB Output is correct
50 Correct 39 ms 4848 KB Output is correct
51 Correct 38 ms 4644 KB Output is correct
52 Correct 25 ms 4256 KB Output is correct
53 Correct 43 ms 3952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 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 1 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 320 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 1 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 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 368 KB Output is correct
21 Correct 2 ms 780 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 3 ms 460 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 3 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 524 KB Output is correct
29 Correct 5 ms 724 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 4 ms 1872 KB Output is correct
32 Correct 5 ms 724 KB Output is correct
33 Correct 5 ms 716 KB Output is correct
34 Correct 3 ms 864 KB Output is correct
35 Correct 6 ms 856 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 4 ms 852 KB Output is correct
38 Correct 1 ms 772 KB Output is correct
39 Correct 50 ms 3904 KB Output is correct
40 Correct 2 ms 724 KB Output is correct
41 Correct 3 ms 992 KB Output is correct
42 Correct 8 ms 852 KB Output is correct
43 Correct 6 ms 936 KB Output is correct
44 Correct 8 ms 2008 KB Output is correct
45 Correct 14 ms 2232 KB Output is correct
46 Correct 35 ms 12128 KB Output is correct
47 Correct 43 ms 4076 KB Output is correct
48 Correct 37 ms 3796 KB Output is correct
49 Correct 19 ms 4800 KB Output is correct
50 Correct 39 ms 4848 KB Output is correct
51 Correct 38 ms 4644 KB Output is correct
52 Correct 25 ms 4256 KB Output is correct
53 Correct 43 ms 3952 KB Output is correct
54 Incorrect 1 ms 212 KB Output isn't correct
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 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 1 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 320 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 1 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 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 368 KB Output is correct
21 Correct 2 ms 780 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 3 ms 460 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 3 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 524 KB Output is correct
29 Correct 5 ms 724 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 4 ms 1872 KB Output is correct
32 Correct 5 ms 724 KB Output is correct
33 Correct 5 ms 716 KB Output is correct
34 Correct 3 ms 864 KB Output is correct
35 Correct 6 ms 856 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 4 ms 852 KB Output is correct
38 Correct 1 ms 772 KB Output is correct
39 Correct 50 ms 3904 KB Output is correct
40 Correct 2 ms 724 KB Output is correct
41 Correct 3 ms 992 KB Output is correct
42 Correct 8 ms 852 KB Output is correct
43 Correct 6 ms 936 KB Output is correct
44 Correct 8 ms 2008 KB Output is correct
45 Correct 14 ms 2232 KB Output is correct
46 Correct 35 ms 12128 KB Output is correct
47 Correct 43 ms 4076 KB Output is correct
48 Correct 37 ms 3796 KB Output is correct
49 Correct 19 ms 4800 KB Output is correct
50 Correct 39 ms 4848 KB Output is correct
51 Correct 38 ms 4644 KB Output is correct
52 Correct 25 ms 4256 KB Output is correct
53 Correct 43 ms 3952 KB Output is correct
54 Incorrect 1 ms 212 KB Output isn't correct
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 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 1 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 320 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 1 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 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 368 KB Output is correct
21 Correct 2 ms 780 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 3 ms 460 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 3 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 524 KB Output is correct
29 Correct 5 ms 724 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 4 ms 1872 KB Output is correct
32 Correct 5 ms 724 KB Output is correct
33 Correct 5 ms 716 KB Output is correct
34 Correct 3 ms 864 KB Output is correct
35 Correct 6 ms 856 KB Output is correct
36 Correct 3 ms 852 KB Output is correct
37 Correct 4 ms 852 KB Output is correct
38 Correct 1 ms 772 KB Output is correct
39 Correct 50 ms 3904 KB Output is correct
40 Correct 2 ms 724 KB Output is correct
41 Correct 3 ms 992 KB Output is correct
42 Correct 8 ms 852 KB Output is correct
43 Correct 6 ms 936 KB Output is correct
44 Correct 8 ms 2008 KB Output is correct
45 Correct 14 ms 2232 KB Output is correct
46 Correct 35 ms 12128 KB Output is correct
47 Correct 43 ms 4076 KB Output is correct
48 Correct 37 ms 3796 KB Output is correct
49 Correct 19 ms 4800 KB Output is correct
50 Correct 39 ms 4848 KB Output is correct
51 Correct 38 ms 4644 KB Output is correct
52 Correct 25 ms 4256 KB Output is correct
53 Correct 43 ms 3952 KB Output is correct
54 Incorrect 1 ms 212 KB Output isn't correct
55 Halted 0 ms 0 KB -