| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1310473 | nanaseyuzuki | Furniture (JOI20_furniture) | C++20 | 184 ms | 26380 KiB |
#include <bits/stdc++.h>
// Kazusa_Megumi
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
using namespace std;
#ifdef LOCAL
#include "C:\Users\Dell\Downloads\template\template\icpc-notebook\Utilities\debug.h"
#else
#define debug(...) 42
#endif
const int mn = 3e3 + 5, mod = 1e9 + 7, inf = 2e9;
int m, n, a[mn][mn], in[mn][mn], out[mn][mn], cnt[mn << 1];
void del(int x, int y){
if(a[x][y]) return;
a[x][y] = 1;
cnt[x + y] --;
if(x > 1 && -- out[x - 1][y] == 0) del(x - 1, y);
if(y > 1 && -- out[x][y - 1] == 0) del(x, y - 1);
if(x < m && -- in[x + 1][y] == 0) del(x + 1, y);
if(y < n && -- in[x][y + 1] == 0) del(x, y + 1);
}
void solve() {
cin >> m >> n;
for(int i = 1; i <= m; i++){
for(int j = 1; j <= n; j++){
in[i][j] = (i > 1) + (j > 1);
out[i][j] = (i < m) + (j < n);
cnt[i + j] ++;
}
}
for(int i = 1; i <= m; i++){
for(int j = 1; j <= n; j++){
int x; cin >> x;
if(x) del(i, j);
}
}
int q; cin >> q;
while(q--){
int x, y; cin >> x >> y;
if(cnt[x + y] > 1){
del(x, y);
cout << 1 << '\n';
}
else cout << a[x][y] << '\n';
}
}
main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
if (fopen("Kazuki.INP", "r")) {
freopen("Kazuki.INP", "r", stdin);
freopen("Kazuki.OUT", "w", stdout);
}
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
