Submission #873645

# Submission time Handle Problem Language Result Execution time Memory
873645 2023-11-15T12:24:37 Z sleepntsheep Catfish Farm (IOI22_fish) C++17
18 / 100
71 ms 14436 KB
#include <cstdio>
#include <cstring>
#include <cassert>
#include <string>
#include <deque>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <iostream>
#include <utility>
#include <numeric>
using namespace std;
using ll=long long;

#define N 200005
#define ALL(x) x.begin(), x.end()

int n, m, *x, *y, *w;

long long max_weights(int n_, int m_, vector<int> x_, vector<int> y_, vector<int> w_)
{
    x = x_.data();
    y = y_.data();
    w = w_.data();
    n = n_, m = m_;

    if (count_if(x, x+m, [](int x){ return x%2; }) == 0) return accumulate(w, w+m, 0ll);
    if (*max_element(x, x+m) <= 1)
    {
        vector<vector<ll>> pf(2, vector<ll>(n+1));
        for (int i = 0; i < m; ++i) pf[x[i]][y[i]] += w[i];
        for (int i = 0; i < 2; ++i)
            for (int j = 1; j < n; ++j)
                pf[i][j] += pf[i][j-1];
        ll z = max(pf[0][n-1], pf[1][n-1]);
        if (n > 2)
        {
            for (int j = 0; j < n; ++j)
                z = max(z, pf[0][j] + pf[1][n-1] - pf[1][j]);
        }
        return z;
    }
    if (*max_element(y, y+m) == 0)
    {
        vector<ll> byx(n);
        for (int i = 0; i < m; ++i) byx[x[i]] += w[i];
        vector<vector<ll>> dp(n+2, vector<ll>(3));
        dp[0][0] = 0; dp[0][1] = byx[0]; dp[1][0] = dp[0][1]; dp[1][1] = byx[1]; dp[1][2] = byx[1];
        for (int i = 2; i < n; ++i)
        {
            dp[i][0] = max({dp[i-1][2], dp[i-1][1], dp[i-1][0]});
            dp[i][1] = dp[i-1][0] + byx[i];
            dp[i][2] = dp[i-1][1] + byx[i];
        }
        return max(dp[n-1][0], dp[n-1][1]);
    }
    if (n <= 300 && *max_element(y, y+m) <= 8)
    {
        ll dp[301][9][3]{0};
        ll pf[301][9]{0};
        for (int i = 0; i < m; ++i) pf[x[i]][y[i]] += w[i];
        for (int i = 0; i < n; ++i) for (int j = 1; j < 9; ++j) pf[i][j] += pf[i][j-1];

        for (int j = 0; j < 9; ++j)
            dp[0][j][0] = 0;
        for (int j = 0; j < 9; ++j)
            dp[1][j][0] = pf[0][j],
            dp[1][j][1] = pf[1][j];

    }
    if (n <= 300)
    {

    }

    return 0;
}


Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:60:12: warning: variable 'dp' set but not used [-Wunused-but-set-variable]
   60 |         ll dp[301][9][3]{0};
      |            ^~
# Verdict Execution time Memory Grader output
1 Correct 18 ms 3672 KB Output is correct
2 Correct 23 ms 4280 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 65 ms 13800 KB Output is correct
6 Correct 71 ms 14436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 38 ms 8984 KB Output is correct
3 Correct 46 ms 10840 KB Output is correct
4 Correct 18 ms 3664 KB Output is correct
5 Correct 22 ms 4432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 436 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 18 ms 5868 KB Output is correct
13 Correct 23 ms 6720 KB Output is correct
14 Correct 19 ms 5724 KB Output is correct
15 Correct 21 ms 6492 KB Output is correct
16 Correct 20 ms 5864 KB Output is correct
17 Correct 22 ms 6228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 6712 KB Output is correct
3 Correct 17 ms 8108 KB Output is correct
4 Correct 14 ms 8028 KB Output is correct
5 Correct 28 ms 10448 KB Output is correct
6 Correct 25 ms 9812 KB Output is correct
7 Correct 27 ms 10436 KB Output is correct
8 Correct 28 ms 10448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 6712 KB Output is correct
3 Correct 17 ms 8108 KB Output is correct
4 Correct 14 ms 8028 KB Output is correct
5 Correct 28 ms 10448 KB Output is correct
6 Correct 25 ms 9812 KB Output is correct
7 Correct 27 ms 10436 KB Output is correct
8 Correct 28 ms 10448 KB Output is correct
9 Incorrect 19 ms 3928 KB 1st lines differ - on the 1st token, expected: '99999', found: '0'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 3672 KB Output is correct
2 Correct 23 ms 4280 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 65 ms 13800 KB Output is correct
6 Correct 71 ms 14436 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 38 ms 8984 KB Output is correct
9 Correct 46 ms 10840 KB Output is correct
10 Correct 18 ms 3664 KB Output is correct
11 Correct 22 ms 4432 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 18 ms 5868 KB Output is correct
19 Correct 23 ms 6720 KB Output is correct
20 Correct 19 ms 5724 KB Output is correct
21 Correct 21 ms 6492 KB Output is correct
22 Correct 20 ms 5864 KB Output is correct
23 Correct 22 ms 6228 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 5 ms 6712 KB Output is correct
26 Correct 17 ms 8108 KB Output is correct
27 Correct 14 ms 8028 KB Output is correct
28 Correct 28 ms 10448 KB Output is correct
29 Correct 25 ms 9812 KB Output is correct
30 Correct 27 ms 10436 KB Output is correct
31 Correct 28 ms 10448 KB Output is correct
32 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
33 Halted 0 ms 0 KB -