| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1355633 | free_de_la_zenith | Furniture (JOI20_furniture) | C++20 | 5091 ms | 5100 KiB |
/**
* author: MINHTPC
*
**/
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin() , a.end()
#define FOR(i ,a , b) for(int i = a ; i <= b ; ++i)
#define bit(mask,i) ((mask>>i)&1)
#define name "task"
#define lo lower_bound
#define up upper_bound
#define count_bit1(x) __builtin_popcountll(x)
#define count_bit01(x) __builtin_clzll(x)
#define count_bit10(x) __builtin_ctzll(x)
using namespace std;
const int N=1e3+5;
int a[N][N];
using pii=pair<int,int>;
int n,m;
int dx[]={1,0};
int dy[]={0,1};
bool check(int x,int y) {
return x>=1 && x<=n && y>=1 && y<=m && a[x][y]==0;
}
bool vis[N][N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
if(fopen("umnik.inp","r")) {
freopen("umnik.inp","r",stdin);
}
cin >> n >> m;
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) cin >> a[i][j];
}
int q;
cin >> q;
while(q--) {
int cx,cy;
cin >> cx >> cy;
int old_val=a[cx][cy];
a[cx][cy]=1;
queue<pii>q;
q.push({1,1});
memset(vis,0,sizeof vis);
vis[1][1]=1;
while(!q.empty()) {
auto cur=q.front();q.pop();
int x=cur.fi,y=cur.se;
for(int i=0;i<2;i++) {
int nx=x+dx[i],ny=y+dy[i];
if(!check(nx,ny)) continue;
if(!vis[nx][ny]) {
vis[nx][ny]=1;
q.push({nx,ny});
}
}
}
if(vis[n][m]==0) {
cout << 0 << '\n';
a[cx][cy]=old_val;
}
else cout << 1 << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
