답안 #1094139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094139 2024-09-28T16:17:43 Z thangdz2k7 Furniture (JOI20_furniture) C++17
0 / 100
1 ms 600 KB
// author : thembululquaUwU
// 3.9.2024

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define endl '\n'

using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;

const int N = 1e3 + 5;
const int mod = 1e9 + 7;

void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}

bool blocked[N][N];
int n, m, f[N + N];

void block(int x, int y){
    f[x + y] --;
    blocked[x][y] = true;
    if (blocked[x - 1][y + 1] && !blocked[x][y + 1]) block(x, y + 1);
    if (blocked[x + 1][y - 1] && !blocked[x + 1][y]) block(x + 1, y);
}

void solve(){
    cin >> n >> m;
    for (int i = 1; i <= n; ++ i) for (int j = 1; j <= m; ++ j) ++ f[i + j];
    for (int i = 1; i <= n; ++ i) for (int j = 1; j <= m; ++ j){
        int a; cin >> a; if (a && !blocked[i][j]) block(i, j);
    }
    int q; cin >> q; while (q --){
        int x, y; cin >> x >> y;
        if (blocked[x][y]) {
            cout << 1 << endl;
            continue;
        }
        if (f[x + y] == 1){
            cout << 0 << endl;
            continue;
        }
        cout << 1 << endl;
        block(x, y);
    }
}

int main(){
    if (fopen("pqh.inp", "r")){
        freopen("pqh.inp", "r", stdin);
        freopen("pqh.out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1; // cin >> t;
    while (t --) solve();
    return 0;
}

Compilation message

furniture.cpp:18:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
furniture.cpp:18:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
furniture.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
furniture.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
furniture.cpp: In function 'int main()':
furniture.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen("pqh.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen("pqh.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -