답안 #558635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
558635 2022-05-07T18:47:07 Z groshi Furniture (JOI20_furniture) C++17
0 / 100
1 ms 980 KB
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
using namespace std;
int t[3000][3000];
vector<pair<int,int> > Q;
bool moge[3000][3000];
int ile_o_sumie[6000];
queue<pair<int,int> > kolejka;
void usun(int x,int y)
{
    kolejka.push({x,y});
    moge[x][y]=0;
    while(!kolejka.empty())
    {
        pair<int,int> para=kolejka.front();
        kolejka.pop();
        x=para.first;
        y=para.second;
        ile_o_sumie[x+y]--;
        if(moge[x][y-1]==1 && moge[x+1][y-1]==0)
        {
            moge[x][y-1]=0;
            kolejka.push({x,y-1});
        }
        if(moge[x-1][y]==1 && moge[x-1][y+1]==0)
        {
            moge[x-1][y]=0;
            kolejka.push({x-1,y});
        }
        if(moge[x][y+1]==1 && moge[x-1][y+1]==0)
        {
            moge[x][y+1]=0;
            kolejka.push({x,y+1});
        }
        if(moge[x+1][y]==1 && moge[x+1][y-1]==0)
        {
            moge[x+1][y]=0;
            kolejka.push({x+1,y});
        }
    }
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n,m,x,y,zap;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            cin>>t[i][j];
            if(t[i][j]==1)
                Q.push_back({i,j});
        }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            moge[i][j]=1;
            ile_o_sumie[i+j]++;
        }
    for(int i=0;i<Q.size();i++)
    {
        usun(Q[i].first,Q[i].second);
    }
    cin>>zap;
    while(zap--)
    {
        cin>>x>>y;
        if(moge[x][y]==0)
        {
            cout<<"1\n";
            continue;
        }
        if(ile_o_sumie[x+y]==1)
        {
            cout<<"0\n";
            continue;
        }
        usun(x,y);
        cout<<"1\n";
    }
    return 0;
}

Compilation message

furniture.cpp: In function 'int main()':
furniture.cpp:64:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int i=0;i<Q.size();i++)
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 852 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 852 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -