Submission #960921

# Submission time Handle Problem Language Result Execution time Memory
960921 2024-04-11T08:47:33 Z danikoynov Cultivation (JOI17_cultivation) C++14
5 / 100
1125 ms 604 KB
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

const int maxn = 310, maxc = 42;

int n, r, c;
int used[2 * maxc][2 * maxc];
int x[maxn], y[maxn];

void solve()
{
    cin >> r >> c;
    cin >> n;
    for (int i = 1; i <= n; i ++)
        cin >> x[i] >> y[i];
    int ans = r + c - 2;
    for (int h = 1; h <= r; h ++)
        for (int w = 1; w <= c; w ++)
        {
            for (int i = 0; i < 2 * maxc; i ++)
                for (int j = 0; j < 2 * maxc; j ++)
                    used[i][j] = 0;

            for (int i = 1; i <= n; i ++)
            {

                for (int dx = x[i]; dx < x[i] + h; dx ++)
                    for (int dy = y[i]; dy < y[i] + w; dy ++)
                    {
                        used[dx][dy] = 1;
                    }
            }

            bool done = false;
            for (int sx = 0; sx < 2 * r; sx ++)
                for (int sy = 0; sy < 2 * c; sy ++)
                {
                    bool tf = true;

                    for (int i = sx; i < sx + r; i ++)
                        for (int j = sy; j < sy + c; j ++)
                        {
                            if (used[i][j] == 0)
                            {
                              //if (h == 3 && w == 2 && sx == 1 && sy == 2)
                                // cout << sx << " : " << sy << " " << i << " " << j << endl;
                                tf = false;
                                break;
                            }
                        }

                    if (tf)
                    {
                        done = true;
                        break;
                    }
                }

                /*if (h == 3 && w == 2)
                {
                     for (int i = 1; i <= 8; i ++, cout << endl)
                         for (int j = 1; j <= 8; j ++)
                         cout << used[i][j] << " ";
                }*/
            if (done)
               {

                    ans = min(ans, h + w - 2);
               }
        }
    cout << ans << endl;
}
int main()
{
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 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 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 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 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 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 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 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 10 ms 344 KB Output is correct
18 Correct 123 ms 444 KB Output is correct
19 Correct 1125 ms 444 KB Output is correct
20 Correct 39 ms 348 KB Output is correct
21 Incorrect 1049 ms 444 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 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 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 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 10 ms 344 KB Output is correct
18 Correct 123 ms 444 KB Output is correct
19 Correct 1125 ms 444 KB Output is correct
20 Correct 39 ms 348 KB Output is correct
21 Incorrect 1049 ms 444 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 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 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 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 10 ms 344 KB Output is correct
18 Correct 123 ms 444 KB Output is correct
19 Correct 1125 ms 444 KB Output is correct
20 Correct 39 ms 348 KB Output is correct
21 Incorrect 1049 ms 444 KB Output isn't correct
22 Halted 0 ms 0 KB -