#include <bits/stdc++.h>
#define int long long
using namespace std;
namespace std {
template <typename T> ostream &operator<<(ostream &out, const vector<T> &vec) {
out << "[";
for (int i = 0; i < (int)vec.size(); ++i) {
out << vec[i];
if (i + 1 < (int)vec.size())
out << ", ";
}
return out << "]";
}
} // namespace std
void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
cout << ' ' << H;
dbg_out(T...);
}
#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
const int MAXN = 1000;
using bs = bitset<MAXN>;
signed main(void) {
ios_base::sync_with_stdio(false);
cin.tie(0);
int nbLig, nbCol;
cin >> nbLig >> nbCol;
vector<bs> accessible(nbLig);
for (int lig = 0; lig < nbLig; ++lig)
for (int col = 0; col < nbCol; ++col) {
int x;
cin >> x;
if (!x)
accessible[lig][col] = 1;
}
int Q;
cin >> Q;
for (int iRequete = 0; iRequete < Q; ++iRequete) {
int r, c;
cin >> r >> c;
--r, --c;
accessible[r][c] = 0;
bs prv;
for (int i = 0; i < nbCol; ++i) {
if (!accessible[0][i])
break;
prv[i] = 1;
}
for (int lig = 1; lig < nbLig; ++lig) {
prv &= accessible[lig];
for (int col = 1; col < nbCol; ++col)
if (accessible[lig][col])
prv[col] = prv[col] || prv[col - 1];
}
cout << prv[nbCol - 1] << '\n';
if (!prv[nbCol - 1])
accessible[r][c] = 1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
340 KB |
Output is correct |
2 |
Correct |
47 ms |
360 KB |
Output is correct |
3 |
Correct |
101 ms |
352 KB |
Output is correct |
4 |
Correct |
214 ms |
384 KB |
Output is correct |
5 |
Correct |
246 ms |
392 KB |
Output is correct |
6 |
Correct |
293 ms |
400 KB |
Output is correct |
7 |
Correct |
210 ms |
328 KB |
Output is correct |
8 |
Correct |
197 ms |
408 KB |
Output is correct |
9 |
Correct |
170 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
340 KB |
Output is correct |
2 |
Correct |
47 ms |
360 KB |
Output is correct |
3 |
Correct |
101 ms |
352 KB |
Output is correct |
4 |
Correct |
214 ms |
384 KB |
Output is correct |
5 |
Correct |
246 ms |
392 KB |
Output is correct |
6 |
Correct |
293 ms |
400 KB |
Output is correct |
7 |
Correct |
210 ms |
328 KB |
Output is correct |
8 |
Correct |
197 ms |
408 KB |
Output is correct |
9 |
Correct |
170 ms |
340 KB |
Output is correct |
10 |
Execution timed out |
5067 ms |
600 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |