답안 #423361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
423361 2021-06-11T02:58:30 Z DanerZein Furniture (JOI20_furniture) C++14
0 / 100
1764 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int ma[110][110];
int X[3]={0,1};
int Y[3]={1,0};
int n,m;
bool floyd(int x,int y){
  queue<ii> q;
  q.push(ii(0,0));
  while(!q.empty()){
    x=q.front().first;
    y=q.front().second;
    if(x==n-1 && y==m-1) return 1;
    q.pop();
    for(int i=0;i<2;i++){
      int xi=x+X[i];
      int yi=y+Y[i];
      if(xi<n && yi<m && ma[xi][yi]!=1){
	q.push(ii(xi,yi));
      }
    }
  }
  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;
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1764 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1764 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -