Submission #680270

# Submission time Handle Problem Language Result Execution time Memory
680270 2023-01-10T11:38:24 Z whqkrtk04 Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 2097152 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
#define fi first
#define se second
const int INF = 1e9+1;
const int P = 1000000007;
const ll LLINF = (ll)1e18+1;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { for(auto i : v) os << i << " "; os << "\n"; return os; }
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) { os << p.fi << " " << p.se; return os; }

typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;

ll pre(int x, int s, int e, vvll &B) {
    if(x < 0 || x >= B.size()) return 0LL;
    return B[x][e] - B[x][s];
}

vll maxpre(int i, vvvll &D) {
    int N = D.size();
    vll T(N+1, 0LL);
    for(int j = 0; j <= N; j++)
        for(int k = 0; k <= j; k++)
            T[j] = max(T[j], D[i-1][j][k]);
    return T;
}

vll maxall(int i, vvvll &D) {
    int N = D.size();
    vll T(N+1, 0LL);
    for(int j = 0; j <= N; j++)
        for(int k = 0; k <= N; k++)
            T[j] = max(T[j], D[i-1][j][k]);
    return T;
}

ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    vvll A(N, vll(N, 0LL));
    for(int i = 0; i < M; i++) A[X[i]][Y[i]] += W[i];
    vvll B(N, vll(N+1, 0LL));
    for(int i = 0; i < N; i++)
        for(int j = 1; j <= N; j++)
            B[i][j] = B[i][j-1]+A[i][j-1];

    vvvll D(N, vvll(N+1, vll(N+1, 0LL)));
    for(int j = 0; j <= N; j++) {
        for(int k = 0; k <= N; k++) {
            if(j > k) D[1][j][k] = pre(2, 0, j, B)+pre(0, k, j, B);
            else D[1][j][k] = pre(2, 0, j, B)+pre(1, j, k, B);
        }
    }
    for(int i = 2; i < N; i++) {
        vll MP = maxpre(i, D), MA = maxall(i, D);
        for(int j = 0; j <= N; j++) {
            for(int k = 0; k <= N; k++) {
                if(j > k) D[i][j][k] = MP[k]-pre(i, 0, k, B)+pre(i+1, 0, j, B)+pre(i-1, k, j, B);
                else D[i][j][k] = MA[k]-pre(i, 0, j, B)+pre(i+1, 0, j, B);
            }
        }
    }
    
    ll ans = 0LL;
    for(int i = 0; i <= N; i++)
        for(int j = 0; j <= N; j++)
            ans = max(ans, D[N-1][i][j]);
    return ans;
}

Compilation message

fish.cpp: In function 'll pre(int, int, int, vvll&)':
fish.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     if(x < 0 || x >= B.size()) return 0LL;
      |                 ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1186 ms 2054420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 304 KB Output is correct
2 Runtime error 941 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 787 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 30 ms 28244 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 30 ms 28244 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 30 ms 28244 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 787 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1186 ms 2054420 KB Time limit exceeded
2 Halted 0 ms 0 KB -