이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 2000 + 7;
int n;
int m;
int a[N][N];
int down[N][N];
void full()
{
down[n + 1][m] = down[n][m + 1] = 1;
for (int i = n; i >= 1; i--)
{
for (int j = m; j >= 1; j--)
{
if (a[i][j] == 0)
{
down[i][j] = (down[i + 1][j] > 0) + (down[i][j + 1] > 0);
}
else
{
down[i][j] = 0;
}
}
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
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;
for (int i = 1; i <= q; i++)
{
int r, c;
cin >> r >> c;
a[r][c] = 1;
full();
if (down[1][1] == 0)
{
a[r][c] = 0;
cout << "0\n";
}
else
{
cout << "1\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |