답안 #358524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
358524 2021-01-25T16:43:32 Z BartolM Furniture (JOI20_furniture) C++17
5 / 100
5000 ms 10264 KB
#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

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);
      |     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 896 KB Output is correct
2 Correct 45 ms 1132 KB Output is correct
3 Correct 94 ms 1152 KB Output is correct
4 Correct 210 ms 1132 KB Output is correct
5 Correct 235 ms 1260 KB Output is correct
6 Correct 284 ms 1388 KB Output is correct
7 Correct 276 ms 1260 KB Output is correct
8 Correct 256 ms 1388 KB Output is correct
9 Correct 210 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 896 KB Output is correct
2 Correct 45 ms 1132 KB Output is correct
3 Correct 94 ms 1152 KB Output is correct
4 Correct 210 ms 1132 KB Output is correct
5 Correct 235 ms 1260 KB Output is correct
6 Correct 284 ms 1388 KB Output is correct
7 Correct 276 ms 1260 KB Output is correct
8 Correct 256 ms 1388 KB Output is correct
9 Correct 210 ms 1388 KB Output is correct
10 Correct 4078 ms 1644 KB Output is correct
11 Correct 164 ms 748 KB Output is correct
12 Execution timed out 5058 ms 10264 KB Time limit exceeded
13 Halted 0 ms 0 KB -