제출 #1295668

#제출 시각아이디문제언어결과실행 시간메모리
1295668baotoan655Furniture (JOI20_furniture)C++20
100 / 100
232 ms6396 KiB
#include <bits/stdc++.h> #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } using namespace std; const int N = 1005; int n, m; int f[N][N]; int cnt[N + N]; void dfs(int i, int j); void go(int i, int j) { if(f[i][j] == 1) return; if(i == 1 && j == 1) return; if(i == n && j == m) return; if((f[i - 1][j] && f[i][j - 1]) || (f[i + 1][j] && f[i][j + 1])){ dfs(i, j); } } void dfs(int i, int j) { if(f[i][j]) return; f[i][j] = 1; --cnt[i + j]; go(i - 1, j); go(i, j - 1); go(i + 1, j); go(i, j + 1); } int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); file("A") else file("task"); cin >> n >> m; for(int i = 0; i <= n + 1; ++i) f[i][0] = f[i][m + 1] = 1; for(int j = 0; j <= m + 1; ++j) f[0][j] = f[n + 1][j] = 1; for(int i= 1; i <= n; ++i) for(int j = 1; j <= m; ++j) ++cnt[i + j]; for(int i = 1; i <= n; ++i) { for(int j = 1; j <= m; ++j) { int x; cin >> x; if(x) dfs(i, j); } } int q; cin >> q; while(q--) { int x, y; cin >> x >> y; if(f[x][y]) cout << 1 << '\n'; else if(cnt[x + y] == 1) cout << 0 << '\n'; else { dfs(x, y); cout << 1 << '\n'; } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

furniture.cpp: In function 'int main()':
furniture.cpp:2:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp:33:5: note: in expansion of macro 'file'
   33 |     file("A") else file("task");
      |     ^~~~
furniture.cpp:2:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp:33:5: note: in expansion of macro 'file'
   33 |     file("A") else file("task");
      |     ^~~~
furniture.cpp:2:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp:33:20: note: in expansion of macro 'file'
   33 |     file("A") else file("task");
      |                    ^~~~
furniture.cpp:2:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp:33:20: note: in expansion of macro 'file'
   33 |     file("A") else file("task");
      |                    ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...