Submission #1071383

# Submission time Handle Problem Language Result Execution time Memory
1071383 2024-08-23T07:03:57 Z Plurm Cultivation (JOI17_cultivation) C++11
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

int r, c;
bitset<1600> moveleft(bitset<1600> mask) {
    for (int i = 0; i < r; i++)
        mask[i * c] = false;
    return mask >> 1;
}
bitset<1600> moveright(bitset<1600> mask) {
    for (int i = 0; i < r; i++)
        mask[i * c + c - 1] = false;
    return mask << 1;
}
bitset<1600> moveup(bitset<1600> mask) {
    for (int i = 0; i < c; i++)
        mask[i] = false;
    return mask >> c;
}
bitset<1600> movedown(bitset<1600> mask) {
    for (int i = 0; i < c; i++)
        mask[(r - 1) * c + i] = false;
    return mask << c;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> r >> c;
    int n;
    cin >> n;
    vector<pair<int, int>> pts;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        pts.push_back({x, y});
    }
    bitset<1600> init(0);
    for (auto p : pts) {
        init[(p.first - 1) * c + p.second - 1] = true;
    }
    for (int ans = 0; ans <= 80; ans++) {
        for (int p = 0; p < c && p <= ans; p++) {
            for (int q = 0; q < c && q <= ans; q++) {
                for (int s = 0; s < r && r <= ans; s++) {
                    int t = ans - p - q - s;
                    if (t < 0 || t >= r)
                        continue;
                    auto state = init;
                    for (int _ = 0; _ < p; _++)
                        state |= moveleft(state);
                    for (int _ = 0; _ < q; _++)
                        state |= moveright(state);
                    for (int _ = 0; _ < s; _++)
                        state |= moveup(state);
                    for (int _ = 0; _ < t; _++)
                        state |= movedown(state);
                    if (state.count() >= r * c) {
                        cout << ans << endl;
                        return 0;
                    }
                    state = init;
                    for (int _ = 0; _ < s; _++)
                        state |= moveup(state);
                    for (int _ = 0; _ < p; _++)
                        state |= moveleft(state);
                    for (int _ = 0; _ < t; _++)
                        state |= movedown(state);
                    for (int _ = 0; _ < q; _++)
                        state |= moveright(state);
                    if (state.count() >= r * c) {
                        cout << ans << endl;
                        return 0;
                    }
                }
            }
        }
    }
}

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:57:39: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |                     if (state.count() >= r * c) {
      |                         ~~~~~~~~~~~~~~^~~~~~~~
cultivation.cpp:70:39: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   70 |                     if (state.count() >= r * c) {
      |                         ~~~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -