답안 #599424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
599424 2022-07-19T13:56:57 Z KarolZ Dango Maker (JOI18_dango_maker) C++14
0 / 100
5 ms 340 KB
#include<iostream>
#include<queue>
#include<set>
using namespace std;
int t[3010][3010];
int il[3010][3010];
//priority_queue< pair<int,pair<pair<int,int>,bool> > >pq;
set< pair<int,pair<pair<int,int>,bool> > >s;
set< pair<int,pair<pair<int,int>,bool> > >::iterator it;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
    int n,m,licz=0,x,y,kt;
    string ss;
    cin>>n>>m;
    for(int i=2;i<=n+1;i++){
        cin>>ss;
        for(int j=2;j<=m+1;j++){
            if(ss[j-2]=='R')t[i][j]=1;
            if(ss[j-2]=='G')t[i][j]=2;
            if(ss[j-2]=='W')t[i][j]=3;
        }
    }
    for(int i=2;i<=n+1;i++){
        for(int j=2;j<=m+1;j++){
            if(t[i][j]==1){
                if(t[i][j+1]==2&&t[i][j+2]==3){
                    il[i][j]++;
                    il[i][j+1]++;
                    il[i][j+2]++;
                    licz++;
                }
                if(t[i+1][j]==2&&t[i+2][j]==3){
                    il[i][j]++;
                    il[i+1][j]++;
                    il[i+2][j]++;
                    licz++;
                }
            }
        }
    }
    //cout<<licz<<'\n';
    for(int i=2;i<=n+1;i++){
        for(int j=2;j<=m+1;j++){
            if(t[i][j]==1){
                if(t[i][j+1]==2&&t[i][j+2]==3){
                    s.insert({il[i][j]+il[i][j+1]+il[i][j+2],{{i,j},0}});
                }
                if(t[i+1][j]==2&&t[i+2][j]==3){
                    s.insert({il[i][j]+il[i+1][j]+il[i+2][j],{{i,j},1}});
                }
            }
        }
    }
    while(1){
        it=s.begin();
        if((*it).first<=3)break;
        x=(*it).second.first.first;
        y=(*it).second.first.second;
        kt=(*it).second.second;
        s.erase(it);
        if(kt==0){
            licz--;
            if(t[x+1][y]==2&&t[x+2][y]==3){
                s.erase({il[x][y]+il[x+1][y]+il[x+2][y],{{x,y},1}});
                s.insert({il[x][y]+il[x+1][y]+il[x+2][y]-1,{{x,y},1}});
            }
            if(t[x-1][y+1]==1&&t[x+1][y+1]==3){
                s.erase({il[x][y+1]+il[x+1][y+1]+il[x-1][y+1],{{x-1,y+1},1}});
                s.insert({il[x][y+1]+il[x+1][y+1]+il[x-1][y+1]-1,{{x-1,y+1},1}});
            }
            if(t[x-1][y+2]==2&&t[x-2][y+2]==1){
                s.erase({il[x][y+2]+il[x-1][y+2]+il[x-2][y+2],{{x-2,y+2},1}});
                s.insert({il[x][y+2]+il[x-1][y+2]+il[x-2][y+2]-1,{{x-2,y+2},1}});
            }
            il[x][y]--;
            il[x][y+1]--;
            il[x][y+2]--;
            //s.insert({il[x][y]+il[x][y+1]+il[x][y+2],{{x,y},0}});
        }
        if(kt==1){
            licz--;
            if(t[x][y+1]==2&&t[x][y+2]==3){
                s.erase({il[x][y]+il[x][y+1]+il[x][y+2],{{x,y},0}});
                s.insert({il[x][y]+il[x][y+1]+il[x][y+2]-1,{{x,y},0}});
            }
            if(t[x+1][y-1]==1&&t[x+1][y+1]==3){
                s.erase({il[x+1][y]+il[x+1][y+1]+il[x+1][y-1],{{x+1,y-1},0}});
                s.insert({il[x+1][y]+il[x+1][y+1]+il[x+1][y-1]-1,{{x+1,y-1},0}});
            }
            if(t[x+2][y-1]==2&&t[x+2][y-2]==1){
                s.erase({il[x+2][y]+il[x+2][y-1]+il[x+2][y-2],{{x+2,y-2},0}});
                s.insert({il[x+2][y]+il[x+2][y-1]+il[x+2][y-2]-1,{{x+2,y-2},0}});
            }
            il[x][y]--;
            il[x+1][y]--;
            il[x+2][y]--;
            //s.insert({il[x][y]+il[x+1][y]+il[x+2][y],{{x,y},1}});
        }
    }
    cout<<licz;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 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 Incorrect 5 ms 340 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 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 Incorrect 5 ms 340 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 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 Incorrect 5 ms 340 KB Output isn't correct
8 Halted 0 ms 0 KB -