Submission #925251

# Submission time Handle Problem Language Result Execution time Memory
925251 2024-02-11T08:15:11 Z IS_Rushdi Catfish Farm (IOI22_fish) C++17
9 / 100
1000 ms 23376 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+1][4][4]{};
    vector<pair<int,int>>to[n+1];
    for(int i = 0; i < m; i++){to[x[i]+1].push_back({y[i]+1,w[i]});}
    for(int i = 0; i <= n; i++){
        to[i].push_back({0,0});
        to[i].push_back({n,0});

    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            dp[0][i][j] = -1e18;
        }
    }
    dp[0][0][0] = 0;
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < to[max(i-2,0)].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];
                    int cur = to[i][v].first;
                    for(auto nodes : to[i-1]){
                        if(cur > max(to[i-2][j].first,to[i-1][k].first)){
                            if(nodes.first > max(to[i-2][j].first,to[i-1][k].first)){
                                now += nodes.second;
                            }
                        }
                    }
                    cur = to[i-1][k].first;
                    for(auto nodes : to[i]){
                        if(cur > to[i][v].first){
                            if(nodes.first > to[i][v].first){
                                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:23:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int j = 0; j < to[max(i-2,0)].size(); j++){
      |                        ~~^~~~~~~~~~~~~~~~~~~~~~~
fish.cpp:24:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             for(int k = 0; k < to[i-1].size(); k++){
      |                            ~~^~~~~~~~~~~~~~~~
fish.cpp:25:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |                 for(int v = 0; v < to[i].size(); v++){
      |                                ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 19124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Execution timed out 1088 ms 21684 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 18268 KB Output is correct
2 Correct 21 ms 18432 KB Output is correct
3 Correct 44 ms 19232 KB Output is correct
4 Correct 36 ms 19804 KB Output is correct
5 Correct 76 ms 23376 KB Output is correct
6 Correct 63 ms 23116 KB Output is correct
7 Correct 66 ms 23124 KB Output is correct
8 Correct 65 ms 23120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 18268 KB Output is correct
2 Correct 21 ms 18432 KB Output is correct
3 Correct 44 ms 19232 KB Output is correct
4 Correct 36 ms 19804 KB Output is correct
5 Correct 76 ms 23376 KB Output is correct
6 Correct 63 ms 23116 KB Output is correct
7 Correct 66 ms 23124 KB Output is correct
8 Correct 65 ms 23120 KB Output is correct
9 Correct 64 ms 23116 KB Output is correct
10 Incorrect 65 ms 13040 KB 1st lines differ - on the 1st token, expected: '36454348383152', found: '41502127735013'
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 19124 KB Time limit exceeded
2 Halted 0 ms 0 KB -