Submission #127566

#TimeUsernameProblemLanguageResultExecution timeMemory
127566VlatkoMaja (COCI18_maja)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int inf = 1e9; const int maxn = 100; int N, M, A, B; ll K, T; ll C[maxn][maxn]; // dp[k][i][j] = max sum for path to here after k steps vector<vector<ll>> cur(maxn, vector<ll>(maxn)); vector<vector<ll>> nxt(maxn, vector<ll>(maxn)); void dp_step() { for (int i = 0; i < N; ++i) { for (int j = 0; i < M; ++j) { nxt[i][j] = -inf; for (int d = 0; d < 4; ++d) { int i1 = i + di[d], j1 = j + dj[d]; if (i1 >= 0 && i1 < N && j1 >= 0 && j1 < M) { nxt[i][j] = max(nxt[i][j], cur[i1][j1] + C[i][j]); } } } } swap(cur, nxt); } void simulate() { for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { ll gains = -inf; for (int d = 0; d < 4; ++d) { int i1 = i + di[d], j1 = j + dj[d]; if (i1 >= 0 && i1 < N && j1 >= 0 && j1 < M) { gains = max(gains, C[i1][j1] + C[i][j]); } } cur[i][j] += gains * (K - 2*T) / 2; } } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> M >> K >> A >> B; --A, --B; T = N * M * 2; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { cin >> C[i][j]; cur[i][j] = -inf; } } cur[A][B] = 0; if (2*T >= K) { for (int i = 0; i < K; ++i) { dp_step(); } } else { // T steps, simulate going back and forth, T steps again for (int i = 0; i < T; ++i) { dp_step(); } simulate(); for (int i = 0; i < T; ++i) { dp_step(); } } cout << cur[A][B] << '\n'; }

Compilation message (stderr)

maja.cpp: In function 'void dp_step()':
maja.cpp:23:18: error: 'di' was not declared in this scope
     int i1 = i + di[d], j1 = j + dj[d];
                  ^~
maja.cpp:23:18: note: suggested alternative: 'd'
     int i1 = i + di[d], j1 = j + dj[d];
                  ^~
                  d
maja.cpp:24:46: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     if (i1 >= 0 && i1 < N && j1 >= 0 && j1 < M) {
                                              ^
maja.cpp:25:43: error: invalid conversion from 'double (*)(double) throw ()' to 'std::vector<long long int>::size_type {aka long unsigned int}' [-fpermissive]
      nxt[i][j] = max(nxt[i][j], cur[i1][j1] + C[i][j]);
                                           ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from maja.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:795:7: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::reference = long long int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
       operator[](size_type __n) _GLIBCXX_NOEXCEPT
       ^~~~~~~~
maja.cpp: In function 'void simulate()':
maja.cpp:38:18: error: 'di' was not declared in this scope
     int i1 = i + di[d], j1 = j + dj[d];
                  ^~
maja.cpp:38:18: note: suggested alternative: 'd'
     int i1 = i + di[d], j1 = j + dj[d];
                  ^~
                  d
maja.cpp:39:46: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     if (i1 >= 0 && i1 < N && j1 >= 0 && j1 < M) {
                                              ^
maja.cpp:40:33: error: invalid types 'll [100] {aka long long int [100]}[double(double) throw ()]' for array subscript
      gains = max(gains, C[i1][j1] + C[i][j]);
                                 ^