Submission #659030

# Submission time Handle Problem Language Result Execution time Memory
659030 2022-11-16T00:00:30 Z pere_gil Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include "fish.h"
#include "bits/stdc++.h"
using namespace std;
         
typedef long long ll;
     
ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w){
	int h=0;
	for(int i=0;i<m;i++) h=max(h,y[i]);
	h+=2;

	ll fish[n][h]={};
	for(int i=0;i<m;i++) fish[x[i]][y[i]+1]=w[i];
	for(int i=0;i<n;i++)
		for(int j=1;j<h;j++)
			fish[i][j]+=fish[i][j-1];

	ll dp[n][2][h][h]={};
	for(int i=1;i<n;i++){
		for(int j=0;j<h;j++){

			// decreasing:
			ll prev=0;
			int pos=0;
			for(int k=h-1;k>=j;k--){
				ll aux=max(dp[i-1][0][k][j],dp[i-1][1][k][j]);
				// hmmmm
				if(aux>=prev){
					pos=k;
					prev=aux;
				}
			}
			
			if(j){
				for(int k=0;k<=j;k++){
					dp[i][0][j][k]+=prev;
					dp[i][0][j][k]+=fish[i][j]-fish[i][k];
				}
			}
			else{
				for(int k=0;k<h;k++){
					dp[i][0][j][k]+=prev;
					if(k>pos) dp[i][0][j][k]+=fish[i-1][k]-fish[i-1][pos];
				}
			}
			
			// increasing:
			prev=0;
			for(int k=0;k<=j;k++)
				prev=max(prev,dp[i-1][1][k][j]);
			for(int k=0;k<h;k++){
				dp[i][1][j][k]+=prev;
				
				if(j>=k) dp[i][1][j][k]+=fish[i][j]-fish[i][k];
				else dp[i][1][j][k]+=fish[i-1][k]-fish[i-1][j];
			}
		}
	}

	/*
	for(int i=0;i<n;i++){
		for(int j=0;j<h;j++){
			for(int k=0;k<h;k++){
				printf("%d:\n",i);
				printf("decreasing:\n");
				printf("%d %d -> %lld\n",j,k,dp[i][0][j][k]);
				printf("increasing:\n");
				printf("%d %d -> %lld\n",j,k,dp[i][1][j][k]);
				printf("\n");
			}
		}
	}
	*/

	ll res=0;
	for(int i=0;i<h;i++)
		for(int j=0;j<h;j++)
			res=max({res,dp[n-1][0][i][j],dp[n-1][1][i][j]});
	
	return res;
}

Compilation message

during RTL pass: expand
fish.cpp: In function 'll max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:18:21: internal compiler error: in make_decl_rtl, at varasm.c:1342
   18 |  ll dp[n][2][h][h]={};
      |                     ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions.