Submission #558633

#TimeUsernameProblemLanguageResultExecution timeMemory
558633groshiFurniture (JOI20_furniture)C++17
0 / 100
2 ms980 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}); while(!kolejka.empty()) { pair<int,int> para=kolejka.front(); kolejka.pop(); x=para.first; y=para.second; moge[x][y]=0; ile_o_sumie[x+y]--; if(moge[x][y-1]==1 && moge[x+1][y-1]==0) kolejka.push({x,y-1}); if(moge[x-1][y]==1 && moge[x-1][y+1]==0) kolejka.push({x-1,y}); if(moge[x][y+1]==1 && moge[x-1][y+1]==0) kolejka.push({x,y+1}); if(moge[x+1][y]==1 && moge[x+1][y-1]==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"; usun(x,y); 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:52: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]
   52 |     for(int i=0;i<Q.size();i++)
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...