제출 #1231427

#제출 시각아이디문제언어결과실행 시간메모리
1231427hainam2k9Furniture (JOI20_furniture)C++20
100 / 100
125 ms3520 KiB
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
#define mp make_pair
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "";
int n,m,q,cnt[2005];
bool f[1005][1005];
void upd(int x, int y){
    --cnt[x+y];
    f[x][y]=1;
    if(f[x-1][y+1]||x==1||y==m){
        if(y<m&&!f[x][y+1]) upd(x,y+1);
        if(x>1&&!f[x-1][y]) upd(x-1,y);
    }
    if(f[x+1][y-1]||x==n||y==1){
        if(x<n&&!f[x+1][y]) upd(x+1,y);
        if(y>1&&!f[x][y-1]) upd(x,y-1);
    }
}
int main()
{
    tt;
    if(fopen((NAME + ".INP").c_str(), "r")) fo;
    cin >> n >> m;
    for(int i = 1; i<=n; ++i)
        for(int j = 1; j<=m; ++j){
            bool x;
            cin >> x;
            if(x&&!f[i][j]) upd(i,j);
            ++cnt[i+j];
        }
    cin >> q;
    while(q--){
        int x,y;
        cin >> x >> y;
        if(f[x][y]||cnt[x+y]>1){
            cout << "1\n";
            if(!f[x][y]) upd(x,y);
        }else cout << "0\n";
    }
}

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

furniture.cpp: In function 'int main()':
furniture.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp:39:45: note: in expansion of macro 'fo'
   39 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
furniture.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
furniture.cpp:39:45: note: in expansion of macro 'fo'
   39 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...