Submission #626603

# Submission time Handle Problem Language Result Execution time Memory
626603 2022-08-11T14:58:38 Z Kaitokid Catfish Farm (IOI22_fish) C++17
23 / 100
1000 ms 36312 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int mx;
ll dp[100009][3][2];
vector<int>g[100009],f[300009];
ll go(int x,int lst,int u)
{
    if(x==mx)return 0;
    if(dp[x][lst][u]!=-1)return dp[x][lst][u];
    for(int i=0;i<g[x].size();i++)
    {
        ll d=0;
        if((u==0) && g[x][i]>g[x-1][lst])
           {
                for(int j=0;j<g[x-1].size();j++)
                if(g[x-1][j]>=g[x-1][lst] && g[x-1][j]<g[x][i])d+=f[x-1][j];
           }
        dp[x][lst][u]=max(dp[x][lst][u],d+go(x+1,i,0));

        for(int j=0;j<g[x].size();j++)
                 if(g[x][j]<g[x-1][lst] && g[x][j]>=g[x][i])d+=f[x][j];


        dp[x][lst][u]=max(dp[x][lst][u],d+go(x+1,i,1));
    }
    return dp[x][lst][u];
}
ll max_weights(int N,int M,vector<int>X,vector<int>Y,vector<int>W)
{
    mx=N;
    for(int i=0;i<M;i++)
    {
        g[X[i]].push_back(Y[i]+1);
        f[X[i]].push_back(W[i]);
    }
    for(int i=0;i<N;i++)
    {
        g[i].push_back(N+1);f[i].push_back(0);
    }
    memset(dp,-1,sizeof dp);
    ll ans=0;
    for(int i=0;i<g[0].size();i++)
       ans=max(ans,go(1,i,0));
       return ans;
}

Compilation message

fish.cpp: In function 'll go(int, int, int)':
fish.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0;i<g[x].size();i++)
      |                 ~^~~~~~~~~~~~
fish.cpp:16:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |                 for(int j=0;j<g[x-1].size();j++)
      |                             ~^~~~~~~~~~~~~~
fish.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(int j=0;j<g[x].size();j++)
      |                     ~^~~~~~~~~~~~
fish.cpp: In function 'll max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i=0;i<g[0].size();i++)
      |                 ~^~~~~~~~~~~~
fish.cpp:43:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   43 |     for(int i=0;i<g[0].size();i++)
      |     ^~~
fish.cpp:45:8: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   45 |        return ans;
      |        ^~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 32320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14292 KB Output is correct
2 Execution timed out 1085 ms 34940 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 31572 KB Output is correct
2 Correct 34 ms 31488 KB Output is correct
3 Correct 63 ms 31028 KB Output is correct
4 Correct 62 ms 32376 KB Output is correct
5 Correct 98 ms 33840 KB Output is correct
6 Correct 104 ms 33952 KB Output is correct
7 Correct 96 ms 33932 KB Output is correct
8 Correct 92 ms 33908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14292 KB Output is correct
2 Correct 8 ms 14292 KB Output is correct
3 Correct 7 ms 14284 KB Output is correct
4 Correct 7 ms 14292 KB Output is correct
5 Correct 7 ms 14292 KB Output is correct
6 Correct 7 ms 14292 KB Output is correct
7 Correct 8 ms 14292 KB Output is correct
8 Correct 7 ms 14332 KB Output is correct
9 Incorrect 8 ms 14440 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '151864197888'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14292 KB Output is correct
2 Correct 8 ms 14292 KB Output is correct
3 Correct 7 ms 14284 KB Output is correct
4 Correct 7 ms 14292 KB Output is correct
5 Correct 7 ms 14292 KB Output is correct
6 Correct 7 ms 14292 KB Output is correct
7 Correct 8 ms 14292 KB Output is correct
8 Correct 7 ms 14332 KB Output is correct
9 Incorrect 8 ms 14440 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '151864197888'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14292 KB Output is correct
2 Correct 8 ms 14292 KB Output is correct
3 Correct 7 ms 14284 KB Output is correct
4 Correct 7 ms 14292 KB Output is correct
5 Correct 7 ms 14292 KB Output is correct
6 Correct 7 ms 14292 KB Output is correct
7 Correct 8 ms 14292 KB Output is correct
8 Correct 7 ms 14332 KB Output is correct
9 Incorrect 8 ms 14440 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '151864197888'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 31572 KB Output is correct
2 Correct 34 ms 31488 KB Output is correct
3 Correct 63 ms 31028 KB Output is correct
4 Correct 62 ms 32376 KB Output is correct
5 Correct 98 ms 33840 KB Output is correct
6 Correct 104 ms 33952 KB Output is correct
7 Correct 96 ms 33932 KB Output is correct
8 Correct 92 ms 33908 KB Output is correct
9 Correct 118 ms 33960 KB Output is correct
10 Correct 65 ms 25220 KB Output is correct
11 Correct 153 ms 36244 KB Output is correct
12 Correct 7 ms 14292 KB Output is correct
13 Correct 7 ms 14300 KB Output is correct
14 Correct 7 ms 14320 KB Output is correct
15 Correct 7 ms 14280 KB Output is correct
16 Correct 7 ms 14292 KB Output is correct
17 Correct 7 ms 14292 KB Output is correct
18 Correct 26 ms 31572 KB Output is correct
19 Correct 26 ms 31576 KB Output is correct
20 Correct 28 ms 31572 KB Output is correct
21 Correct 24 ms 31596 KB Output is correct
22 Correct 94 ms 33836 KB Output is correct
23 Correct 152 ms 36296 KB Output is correct
24 Correct 214 ms 36312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 32320 KB Time limit exceeded
2 Halted 0 ms 0 KB -