Submission #246488

# Submission time Handle Problem Language Result Execution time Memory
246488 2020-07-09T12:18:55 Z proma Colouring a rectangle (eJOI19_colouring) C++17
10 / 100
7 ms 1024 KB
#include <bits/stdc++.h>
#define endl "\n"
#define int long long
#define see(x) cerr<<#x<<"="<<x<<endl;

using namespace std;

int m, n, a[10000], b[10000], g[1000][1000];

int32_t main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> m >> n;

    for (int i = 0; i < m+n-1; ++ i)
        cin >> a[i];
    for (int i = 0; i < m+n-1; ++ i)
        cin >> b[i];

    int ans = 1e18;
    for (int i = 1; i < (1 << (m+m+n+n-2)); ++ i) {
        int k = i, x = 0, y = n-1, sum = 0;
        for (int i = 0; i < m; ++ i)
            for (int j = 0; j < n; ++ j)
                g[i][j] = 0;

        for (int j = 0; j < m+n-1; ++ j) {
            if (k & 1) {
                sum += a[j];
                for (int xx = x, yy = y; xx <= m-1 and yy <= n-1; ++ xx, ++ yy)
                    g[xx][yy] = 1;
            }
            k >>= 1;
            if (y > 0) -- y;
            else ++ x;
        }
        x = y = 0;
        for (int j = 0; j < m+n-1; ++ j) {
            if (k & 1) {
                sum += b[j];
                for (int xx = x, yy = y; xx <= m-1 and yy >= 0; ++ xx, -- yy)
                    g[xx][yy] = 1;
            }
            k >>= 1;
            if (y < n-1) ++ y;
            else ++ x;
        }

        int f = 1;
        for (int i = 0; i < m; ++ i)
            for (int j = 0; j < n; ++ j)
                f &= g[i][j];

        if (f) ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Incorrect 5 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Incorrect 5 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Incorrect 5 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Incorrect 5 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -