Submission #423360

# Submission time Handle Problem Language Result Execution time Memory
423360 2021-06-11T02:54:07 Z DanerZein Furniture (JOI20_furniture) C++14
0 / 100
5000 ms 332 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ma[110][110];
int X[3]={0,1};
int Y[3]={1,0};
int n,m;
bool floyd(int x,int y){
  if(x==n-1 && y==m-1) return 1;
  for(int k=0;k<2;k++){
    int xi=x+X[k];
    int yi=y+Y[k];
    if(yi<m && xi<n &&  ma[xi][yi]!=1 && floyd(xi,yi)) return 1;
  }
  return 0;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin>>n>>m;
  for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>ma[i][j];
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int a,b;
    cin>>a>>b;
    a--; b--;
    ma[a][b]=1;
    if(floyd(0,0)) cout<<"1\n";
    else{
      cout<<"0\n";
      ma[a][b]=0;
    }
  }
}
# Verdict Execution time Memory Grader output
1 Correct 464 ms 332 KB Output is correct
2 Execution timed out 5025 ms 332 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 464 ms 332 KB Output is correct
2 Execution timed out 5025 ms 332 KB Time limit exceeded
3 Halted 0 ms 0 KB -