Submission #866959

#TimeUsernameProblemLanguageResultExecution timeMemory
866959edogawa_somethingFurniture (JOI20_furniture)C++17
5 / 100
5032 ms7352 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vii; typedef pair<ll,ll> pii; #define F first #define S second #define pb push_back #define all(v) v.begin(),v.end() const ll M=1001; ll n,m; bool a[M][M]; int c[M][M]; bool chk(ll x=0,ll y=0){ if(x==n-1&&y==m-1) return 1; if(c[x][y]>-1) return c[x][y]; if(a[x][y]) return 0; bool res=0; if(x<n-1) res|=chk(x+1,y); if(y<m-1) res|=chk(x,y+1); c[x][y]=res; return res; } int main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin>>n>>m; for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cin>>a[i][j]; } ll q; cin>>q; while(q--){ for(int i=0;i<n;i++){ for(int j=0;j<m;j++) c[i][j]=-1; } ll x,y; cin>>x>>y; x--,y--; a[x][y]=1; if(chk()) cout<<1<<'\n'; else{ cout<<0<<'\n'; a[x][y]=0; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...