Submission #358524

#TimeUsernameProblemLanguageResultExecution timeMemory
358524BartolMFurniture (JOI20_furniture)C++17
5 / 100
5058 ms10264 KiB
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;

const int INF=0x3f3f3f3f;
const int N=1005;

int n, m, q;
int mat[N][N];
int dp[N][N], cnt[N];
int dx[4]={-1, 0, 1, 0};
int dy[4]={0, 1, 0, -1};
queue <pii> Q;

int ok(int x, int y) {
    mat[x][y]=0;
    dp[0][1]=1;
    for (int i=1; i<=n; ++i) {
        for (int j=1; j<=m; ++j) {
            dp[i][j]=(dp[i-1][j] || dp[i][j-1]) && mat[i][j];
        }
    }
    mat[x][y]=1;
    return dp[n][m];
}

void solve() {

    while (q--) {
        int x, y;
        scanf("%d %d", &x, &y);
        if (ok(x, y)) {
            printf("1\n");
            mat[x][y]=0;
        }
        else printf("0\n");
    }
}

void load() {
    scanf("%d %d", &n, &m);
    for (int i=1; i<=n; ++i) {
        for (int j=1; j<=m; ++j) {
            scanf("%d", &mat[i][j]);
            mat[i][j]^=1;
        }
    }
    scanf("%d", &q);
}

int main() {
    load();
    solve();
    return 0;
}

Compilation message (stderr)

furniture.cpp: In function 'void solve()':
furniture.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
furniture.cpp: In function 'void load()':
furniture.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
furniture.cpp:54:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   54 |             scanf("%d", &mat[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~
furniture.cpp:58:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   58 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...