Submission #925260

# Submission time Handle Problem Language Result Execution time Memory
925260 2024-02-11T08:32:05 Z IS_Rushdi Catfish Farm (IOI22_fish) C++17
9 / 100
1000 ms 26264 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;

long long max_weights(int n,int m,vector<int>x,vector<int>y,vector<int>w){
    long long dp[n+2][4][4]{};
    
    vector<pair<int,int>>hv[n+2];
    vector<int>to[n+2];
    for(int i = 0; i < m; i++){
        hv[x[i]+2].push_back({y[i]+1,w[i]});
        to[x[i]+2].push_back(y[i]);    
    }

    for(int i = 0; i <= n; i++){
        to[i].push_back(0);
        if(i > 1){
            to[i].push_back(n+3);
        }
    }
    long long ans = 0;
    for(int i = 2; i <= n+1; i++){
        int sz = 0;
        for(int j = 0; j < to[i-2].size(); j++){
            for(int k = 0; k < to[i-1].size(); k++){
                for(int v = 0; v < to[i].size(); v++){
                    long long now = dp[i-1][k][j];
                    for(auto nodes : hv[i-1]){
                        if(nodes.first > max(to[i-2][j],to[i-1][k])){
                            if(nodes.first <= to[i][v]){
                                now += nodes.second;
                            }
                        }
                    }
                    for(auto nodes : hv[i]){
                        if(nodes.first > to[i][v]){
                            if(nodes.first <= to[i-1][k]){
                                now += nodes.second;
                            }
                        }
                    }
                    
                    dp[i][v][k] = max(dp[i][v][k],now);
                    ans = max(ans,now);
                }
            }
        }
    }
    return ans;
}

// int main(){
//     cout << max_weights(5, 4, {0, 1, 4, 3}, {2, 1, 4, 3}, {5, 2, 1, 3}) << '\n';
// }

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:24:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int j = 0; j < to[i-2].size(); j++){
      |                        ~~^~~~~~~~~~~~~~~~
fish.cpp:25:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             for(int k = 0; k < to[i-1].size(); k++){
      |                            ~~^~~~~~~~~~~~~~~~
fish.cpp:26:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |                 for(int v = 0; v < to[i].size(); v++){
      |                                ~~^~~~~~~~~~~~~~
fish.cpp:23:13: warning: unused variable 'sz' [-Wunused-variable]
   23 |         int sz = 0;
      |             ^~
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 21476 KB Time limit exceeded
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: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 20764 KB Output is correct
2 Correct 19 ms 20696 KB Output is correct
3 Correct 39 ms 21588 KB Output is correct
4 Correct 33 ms 22612 KB Output is correct
5 Correct 64 ms 26192 KB Output is correct
6 Correct 66 ms 26264 KB Output is correct
7 Correct 70 ms 26252 KB Output is correct
8 Correct 65 ms 26192 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: '2'
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: '2'
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: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 20764 KB Output is correct
2 Correct 19 ms 20696 KB Output is correct
3 Correct 39 ms 21588 KB Output is correct
4 Correct 33 ms 22612 KB Output is correct
5 Correct 64 ms 26192 KB Output is correct
6 Correct 66 ms 26264 KB Output is correct
7 Correct 70 ms 26252 KB Output is correct
8 Correct 65 ms 26192 KB Output is correct
9 Incorrect 65 ms 26080 KB 1st lines differ - on the 1st token, expected: '99999', found: '99998'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 21476 KB Time limit exceeded
2 Halted 0 ms 0 KB -