Submission #260097

# Submission time Handle Problem Language Result Execution time Memory
260097 2020-08-09T09:51:49 Z SamAnd Wombats (IOI13_wombats) C++17
55 / 100
20000 ms 60576 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops","O3")
#include "wombats.h"
//#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
const int N = 5003, M = 202, INF = 1000000009;

int n, m;
int h[N][N], v[N][N];

int ans[M][M];

int dp[N][M];
void clc()
{
    for (int f = 0; f < m; ++f)
    {
        for (int i = n - 1; i >= 0; --i)
        {
            if (i == n - 1)
            {
                for (int j = 0; j < m; ++j)
                {
                    if (j == f)
                        dp[i][j] = 0;
                    else
                        dp[i][j] = INF;
                }
            }
            else
            {
                for (int j = 0; j < m; ++j)
                {
                    dp[i][j] = dp[i + 1][j] + v[i][j];
                }
            }
            int minu = INF;
            for (int j = 0; j < m; ++j)
            {
                dp[i][j] = min(dp[i][j], minu);
                minu = min(minu, dp[i][j]);
                minu += h[i][j];
            }
            minu = INF;
            for (int j = m - 1; j >= 0; --j)
            {
                dp[i][j] = min(dp[i][j], minu);
                minu = min(minu, dp[i][j]);
                if (j)
                    minu += h[i][j - 1];
            }
        }
        for (int s = 0; s < m; ++s)
        {
            ans[s][f] = dp[0][s];
        }
    }
}

void init(int R, int C, int H[5000][200], int V[5000][200])
{
    n = R;
    m = C;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m - 1; ++j)
        {
            h[i][j] = H[i][j];
        }
    }
    for (int i = 0; i < n - 1; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            v[i][j] = V[i][j];
        }
    }
    clc();
}

void changeH(int P, int Q, int W)
{
    h[P][Q] = W;
    clc();
}

void changeV(int P, int Q, int W)
{
    v[P][Q] = W;
    clc();
}

int escape(int V1, int V2)
{
    return ans[V1][V2];
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
wombats.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops","O3")
# Verdict Execution time Memory Grader output
1 Correct 77 ms 28544 KB Output is correct
2 Correct 74 ms 28544 KB Output is correct
3 Correct 160 ms 30200 KB Output is correct
4 Correct 76 ms 28544 KB Output is correct
5 Correct 72 ms 28544 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 93 ms 1656 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 706 ms 1572 KB Output is correct
2 Correct 316 ms 1536 KB Output is correct
3 Correct 710 ms 1656 KB Output is correct
4 Correct 689 ms 1660 KB Output is correct
5 Correct 688 ms 1656 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 2009 ms 1580 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 196 ms 52480 KB Output is correct
2 Correct 187 ms 52480 KB Output is correct
3 Correct 199 ms 52480 KB Output is correct
4 Correct 244 ms 53368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 706 ms 1700 KB Output is correct
2 Correct 321 ms 1572 KB Output is correct
3 Correct 750 ms 1584 KB Output is correct
4 Correct 702 ms 1656 KB Output is correct
5 Correct 689 ms 1580 KB Output is correct
6 Correct 201 ms 52540 KB Output is correct
7 Correct 176 ms 52480 KB Output is correct
8 Correct 199 ms 52552 KB Output is correct
9 Correct 255 ms 53540 KB Output is correct
10 Correct 78 ms 28544 KB Output is correct
11 Correct 73 ms 28536 KB Output is correct
12 Correct 163 ms 30200 KB Output is correct
13 Correct 74 ms 28616 KB Output is correct
14 Correct 72 ms 28544 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 92 ms 1528 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1970 ms 1656 KB Output is correct
28 Execution timed out 20079 ms 56540 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 702 ms 1536 KB Output is correct
2 Correct 311 ms 1656 KB Output is correct
3 Correct 710 ms 1656 KB Output is correct
4 Correct 692 ms 1536 KB Output is correct
5 Correct 695 ms 1704 KB Output is correct
6 Correct 202 ms 52472 KB Output is correct
7 Correct 172 ms 52480 KB Output is correct
8 Correct 198 ms 52480 KB Output is correct
9 Correct 250 ms 53368 KB Output is correct
10 Correct 75 ms 28544 KB Output is correct
11 Correct 73 ms 28544 KB Output is correct
12 Correct 162 ms 30200 KB Output is correct
13 Correct 84 ms 28664 KB Output is correct
14 Correct 74 ms 28620 KB Output is correct
15 Correct 4609 ms 60452 KB Output is correct
16 Execution timed out 20056 ms 60576 KB Time limit exceeded
17 Halted 0 ms 0 KB -