제출 #1310472

#제출 시각아이디문제언어결과실행 시간메모리
1310472nanaseyuzukiFurniture (JOI20_furniture)C++20
100 / 100
182 ms26256 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(a[x][y] || cnt[x + y] > 1){ del(x, y); cout << 1 << '\n'; } else cout << 0 << '\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) 메시지

furniture.cpp:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   58 | main() {
      | ^~~~
furniture.cpp: In function 'int main()':
furniture.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen("Kazuki.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen("Kazuki.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...