Submission #558636

#TimeUsernameProblemLanguageResultExecution timeMemory
558636groshiFurniture (JOI20_furniture)C++17
100 / 100
288 ms22768 KiB
#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++) { if(moge[Q[i].first][Q[i].second]==0) { continue; } 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 (stderr)

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++)
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...