Submission #600011

# Submission time Handle Problem Language Result Execution time Memory
600011 2022-07-20T11:41:32 Z Piokemon Furniture (JOI20_furniture) C++17
0 / 100
1 ms 340 KB
     #include <bits/stdc++.h>
    using namespace std;
     
    int d[2][2] = {{1,0},{0,1}};
    string plansza[3009];
    int i_prze[3009][3009][2];
    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;
    }
     
    void aktualizuj(int x, int y, int z, int &p){
        if (check(x,y,z)){
            i_prze[x][y][z] -= 1;
            if (i_prze[x][y][z] < 0 || i_prze[x][y][z] > 3){
                return;
            }
            wybierz[i_prze[x][y][z]].push_back({{x,y},z});
            p = min(p, i_prze[x][y][z]);
        }
    }
     
    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;
        plansza[0] = '#' * (m+6);
        for (int x=1;x<=n;x++){
            cin >> plansza[x];
            plansza[x] = '#' + plansza[x] + '#';
        }
        plansza[n+1] = '#' * (m+6);
        for (x=1;x<=n;x++){
            for (y=1;y<=m;y++){
                for (z=0;z<2;z++){
                    if (!check(x,y,z)){
                        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<=3){
            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;
            if (check(x,y,!z)){
                aktualizuj(x+1,y-1,z,p);
                aktualizuj(x+2,y-2,z,p);
            }
            if (check(x-1,y+1,!z)){
                aktualizuj(x+1,y-1,z,p);
                aktualizuj(x-1,y+1,z,p);
            }
            if (check(x-2,y+2,!z)){
                aktualizuj(x-1,y+1,z,p);
                aktualizuj(x-2,y+2,z,p);
            }
            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';
        }
        cout << odp << "\n";
        return 0;
    }
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -