답안 #599962

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
599962 2022-07-20T10:49:15 Z Piokemon Dango Maker (JOI18_dango_maker) C++17
13 / 100
1 ms 468 KB
 #include <bits/stdc++.h>
using namespace std;

int d[2][2] = {{1,0},{0,1}};
string plansza[1009];
int i_prze[1009][1009][4];
deque<pair<pair<int,int>,int>> wybierz[4];
int n,m;

bool check(int x, int y, int z){
    if (x<1 || x>n || y<1 || y>m || x+d[z][0]*2<1 || x+d[z][0]*2>n || y+d[z][1]*2<1 || y+d[z][1]*2>m){
        return 0;
    }
    if ((plansza[x][y] == 'R') && (plansza[x + d[z][0]][y + d[z][1]] == 'G') && (plansza[x + d[z][0]*2][y + d[z][1]*2] == 'W')){
        return 1;
    }
    return 0;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int odp = 0,p=0,x,y,z;
    pair<pair<int,int>,int> ter;
    cin >> n >> m;
    for (int x=1;x<=n;x++){
        cin >> plansza[x];
        plansza[x] = '#' + plansza[x];
    }
    for (x=1;x<=n;x++){
        for (y=1;y<=m;y++){
            for (z=0;z<2;z++){
                if (!check(x,y,z)){
                    i_prze[x][y][z] = -1;
                    continue;
                }
                i_prze[x][y][z] = 0;
                if (z==0){
                    if (check(x,y,1)){
                        i_prze[x][y][z] += 1;
                    }
                    if (check(x+1, y-1, 1)){
                        i_prze[x][y][z] += 1;
                    }
                    if (check(x+2, y-2, 1)){
                        i_prze[x][y][z] += 1;
                    }
                }
                else{
                    if (check(x,y,0)){
                        i_prze[x][y][z] += 1;
                    }
                    if (check(x-1, y+1, 0)){
                        i_prze[x][y][z] += 1;
                    }
                    if (check(x-2, y+2, 0)){
                        i_prze[x][y][z] += 1;
                    }
                }
                wybierz[i_prze[x][y][z]].push_back({{x,y},z});
            }
        }
    }
    while(p<4){
        if (wybierz[p].empty()){
            p += 1;
            continue;
        }
        ter = wybierz[p].front();
        wybierz[p].pop_front();
        x = ter.first.first; y = ter.first.second; z = ter.second;
        if (!check(x,y,z) || i_prze[x][y][z] != p){
            continue;
        }
        odp += 1;
        plansza[x][y] = 'X';
        plansza[x+d[z][0]][y+d[z][1]] = 'X';
        plansza[x + d[z][0]*2][y + d[z][1]*2] = 'X';
        if (check(x,y,!z)){
            if (check(x+1,y-1,z)){
                i_prze[x+1][y-1][z] -= 1;
                wybierz[i_prze[x+1][y-1][z]].push_back({{x+1,y-1},z});
                p = min(p, i_prze[x+1][y-1][z]);
            }
            if (check(x+2,y-2,z)){
                i_prze[x+2][y-2][z] -= 1;
                wybierz[i_prze[x+2][y-2][z]].push_back({{x+2,y-2},z});
                p = min(p, i_prze[x+2][y-2][z]);
            }
        }
        if (check(x-1,y+1,!z)){
            if (check(x+1,y-1,z)){
                i_prze[x+1][y-1][z] -= 1;
                wybierz[i_prze[x+1][y-1][z]].push_back({{x+1,y-1},z});
                p = min(p, i_prze[x+1][y-1][z]);
            }
            if (check(x-1,y+1,z)){
                i_prze[x-1][y+1][z] -= 1;
                wybierz[i_prze[x-1][y+1][z]].push_back({{x-1,y+1},z});
                p = min(p, i_prze[x-1][y+1][z]);
            }
        }
        if (check(x-2,y+2,!z)){
            if (check(x-1,y+1,z)){
                i_prze[x-1][y+1][z] -= 1;
                wybierz[i_prze[x-1][y+1][z]].push_back({{x-1,y+1},z});
                p = min(p, i_prze[x-1][y+1][z]);
            }
            if (check(x-2,y+2,z)){
                i_prze[x-2][y+2][z] -= 1;
                wybierz[i_prze[x-2][y+2][z]].push_back({{x-2,y+2},z});
                p = min(p, i_prze[x-2][y+2][z]);
            }
        }
    }
    cout << odp << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 360 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 360 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Incorrect 1 ms 340 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 360 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 360 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Incorrect 1 ms 340 KB Output isn't correct
28 Halted 0 ms 0 KB -