답안 #697573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
697573 2023-02-10T11:52:44 Z Ninja_Kunai Furniture (JOI20_furniture) C++14
0 / 100
2 ms 340 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
 
using namespace std;
template <class X, class Y> bool minimize(X &a, Y b) {
    if (a > b) return a = b, true;
    return false;
}
template <class X, class Y> bool maximize(X &a, Y b) {
    if (a < b) return a = b, true;
    return false;
}
 
const int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int N = 1e3 + 7;
int n, m, q;
bool a[N][N];
int cnt[N + N];
 
signed main() {
	freopen("ROOM.inp", "r", stdin);
	freopen("ROOM.out", "w", stdout);
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i ++) {
    for (int j = 1; j <= m; j ++) {
      a[i][j] = 1;
      cnt[i + j] ++;
    }
  }
 
  auto rem = [&](int x, int y) {
    queue<pair<int, int>> q;
    q.emplace(x, y);
    while (!q.empty()) {
      tie(x, y) = q.front();
      q.pop();
      if (!a[x][y]) {
        continue;
      }
      a[x][y] = false;
      cnt[x + y] --;
    }
  };
 
  for (int i = 1; i <= n; i ++) {
    for (int j = 1; j <= m; j ++) {
      char c; cin >> c;
      if (c == '1') {
        rem(i, j);        
      }
    }
  }
  cin >> q;
  while (q --) {
    int x, y; cin >> x >> y;
    if (cnt[x + y] == 1 && a[x][y]) {
      cout << 0 << '\n';
    } else {
      cout << 1 << '\n';
      rem(x, y);
    }
  }
  return 0;
}

Compilation message

furniture.cpp: In function 'int main()':
furniture.cpp:24:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  freopen("ROOM.inp", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp:25:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  freopen("ROOM.out", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -