Submission #293759

# Submission time Handle Problem Language Result Execution time Memory
293759 2020-09-08T11:34:46 Z BThero Furniture (JOI20_furniture) C++17
5 / 100
5000 ms 1016 KB
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = (int)1e3 + 5;
const int MAXM = (int)1e6 + 9;

int dp[MAXN][MAXN];
char s[MAXN][MAXN];
int n, m, q;

void solve() {
  scanf("%d %d", &n, &m);
  
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf(" %c", &s[i][j]);
    }
  }
  
  scanf("%d", &q);
  
  for (int i = 1; i <= q; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    s[x][y] = '1';
    
    for (int x = n - 1; ~x; --x) {
      for (int y = m - 1; ~y; --y) {
        if (x == n - 1 && y == m - 1) {
          dp[x][y] = 1;
          continue;
        }
        
        dp[x][y] = 0;
      
        if (s[x][y] != '1') {
          dp[x][y] |= dp[x + 1][y];
          dp[x][y] |= dp[x][y + 1];
        }
      }
    }
    
    if (dp[0][0]) {
      printf("1\n");
    }
    else {
      printf("0\n");
      s[x][y] = '0';
    }
  }
}

int main() {
  int tt = 1;
  
  while (tt--) {
    solve();
  }

  return 0;
}

Compilation message

furniture.cpp: In function 'void solve()':
furniture.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |   scanf("%d %d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~~
furniture.cpp:29:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |       scanf(" %c", &s[i][j]);
      |       ~~~~~^~~~~~~~~~~~~~~~~
furniture.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |   scanf("%d", &q);
      |   ~~~~~^~~~~~~~~~
furniture.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   37 |     scanf("%d %d", &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 640 KB Output is correct
2 Correct 59 ms 768 KB Output is correct
3 Correct 145 ms 768 KB Output is correct
4 Correct 323 ms 968 KB Output is correct
5 Correct 345 ms 876 KB Output is correct
6 Correct 428 ms 888 KB Output is correct
7 Correct 278 ms 888 KB Output is correct
8 Correct 260 ms 888 KB Output is correct
9 Correct 258 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 640 KB Output is correct
2 Correct 59 ms 768 KB Output is correct
3 Correct 145 ms 768 KB Output is correct
4 Correct 323 ms 968 KB Output is correct
5 Correct 345 ms 876 KB Output is correct
6 Correct 428 ms 888 KB Output is correct
7 Correct 278 ms 888 KB Output is correct
8 Correct 260 ms 888 KB Output is correct
9 Correct 258 ms 1016 KB Output is correct
10 Execution timed out 5049 ms 828 KB Time limit exceeded
11 Halted 0 ms 0 KB -