Submission #1096487

# Submission time Handle Problem Language Result Execution time Memory
1096487 2024-10-04T15:32:56 Z arman_ferdous Cultivation (JOI17_cultivation) C++17
5 / 100
2000 ms 604 KB
#ifdef DeBuG
#include "debug.h"
#else
#include <bits/stdc++.h>
#define dbg(...)
#endif
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(v) (int)(v).size()
#define all(v) begin(v),end(v)
#define rep(i,a,b) for (int i=(a);i<(b);++i)
using ll = long long; template <class T> using V = vector<T>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

bool check (V<bitset<41>> &f, int r, int c) {
    for (int i = 1; i <= r; ++i) for (int j = 1; j <= c; ++j) 
        if (f[i][j] == 0) return false;
    return true;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int r, c, n;
    cin >> r >> c >> n;
    V<int> x(n), y(n);
    for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];

    int ans = r + c - 2;
    V<bitset<41>> b(41);
    for (int i = 0; i < n; ++i) b[x[i]][y[i]] = 1;

    for (int u = 0; u < r; ++u) for (int d = 0; d < r; ++d) {
        V<bitset<41>> f = b;
        for (int i = 0; i < u; ++i) {
            for (int j = 1; j < r; ++j) f[j] |= f[j + 1];
        }
        for (int i = 0; i < d; ++i) {
            for (int j = r; j > 1; --j) f[j] |= f[j - 1];
        }

        for (int l = 0; l < c; ++l) for (int ri = 0; ri < c; ++ri) {
            V<bitset<41>> foo = f;
            for (int i = 0; i < l; ++i) for (int j = 1; j <= r; ++j) foo[j] |= foo[j] << 1;
            for (int i = 0; i < ri; ++i) for (int j = 1; j <= r; ++j) foo[j] |= foo[j] >> 1;

            if (check(foo, r, c) && u + d + l + ri < ans) { 
                dbg(u, d, l, ri);
                ans = min(ans, u + d + l + ri);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 24 ms 344 KB Output is correct
18 Correct 276 ms 432 KB Output is correct
19 Execution timed out 2021 ms 344 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 24 ms 344 KB Output is correct
18 Correct 276 ms 432 KB Output is correct
19 Execution timed out 2021 ms 344 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 24 ms 344 KB Output is correct
18 Correct 276 ms 432 KB Output is correct
19 Execution timed out 2021 ms 344 KB Time limit exceeded
20 Halted 0 ms 0 KB -