Submission #922502

# Submission time Handle Problem Language Result Execution time Memory
922502 2024-02-05T15:03:33 Z elotelo966 Growing Vegetable is Fun 3 (JOI19_ho_t3) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY 1000000005
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mid (start+end)/2
#define lim 405
#define fi first
#define se second
int n;// 1 2 3
vector<int> v[4];
int dp[lim][lim][lim][4];
int gec[4][lim][4][lim];// renk index diğer index

inline int dpp(int red,int gre,int yel,int sira,int renk){
	if(sira>=n){
		return 0;
	}
	if(~dp[red][gre][yel][renk])return dp[red][gre][yel][renk];
	int yum=OYY;
	if(renk!=1 && red<(int)v[1].size()){
		int deg=0,deg2=0;
		if(gre>0)deg=gec[1][red][2][gre-1];
		if(yel>0)deg2=gec[1][red][3][yel-1];
		yum=min(yum,dpp(red+1,gre,yel,sira+1,1)+v[1][red]+deg+deg2-sira);
	}
	if(renk!=2 && gre<(int)v[2].size()){
		int deg=0,deg2=0;
		if(red>0)deg=gec[2][gre][1][red-1];
		if(yel>0)deg2=gec[2][gre][3][yel-1];
		yum=min(yum,dpp(red,gre+1,yel,sira+1,2)+v[2][gre]+deg+deg2-sira);	
	}
	if(renk!=3 && yel<(int)v[3].size()){
		int deg=0,deg2=0;
		if(red>0)deg=gec[3][yel][1][red-1];
		if(gre>0)deg2=gec[3][yel][2][gre-1];
		yum=min(yum,dpp(red,gre,yel+1,sira+1,3)+v[3][yel]+deg+deg2-sira);
	}
	return dp[red][gre][yel][renk]=yum;
}

int32_t main(){
	faster
	memset(dp,-1,sizeof(dp));
	cin>>n;
	string s;cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='R')v[1].push_back(i);
		else if(s[i]=='G')v[2].push_back(i);
		else v[3].push_back(i);
	}
	for(int i=0;i<(int)v[1].size();i++){
		int tut=0;
		for(int j=0;j<(int)v[2].size();j++){
			if(v[1][i]<v[2][j])tut++;
			gec[1][i][2][j]=tut;
		}
	}
	for(int i=0;i<(int)v[1].size();i++){
		int tut=0;
		for(int j=0;j<(int)v[3].size();j++){
			if(v[1][i]<v[3][j])tut++;
			gec[1][i][3][j]=tut;
		}
	}
	for(int i=0;i<(int)v[2].size();i++){
		int tut=0;
		for(int j=0;j<(int)v[1].size();j++){
			if(v[2][i]<v[1][j])tut++;
			gec[2][i][1][j]=tut;
		}
	}
	for(int i=0;i<(int)v[2].size();i++){
		int tut=0;
		for(int j=0;j<(int)v[3].size();j++){
			if(v[2][i]<v[3][j])tut++;
			gec[2][i][3][j]=tut;
		}
	}
	for(int i=0;i<(int)v[3].size();i++){
		int tut=0;
		for(int j=0;j<(int)v[1].size();j++){
			if(v[3][i]<v[1][j])tut++;
			gec[3][i][1][j]=tut;
		}
	}
	for(int i=0;i<(int)v[3].size();i++){
		int tut=0;
		for(int j=0;j<(int)v[2].size();j++){
			if(v[3][i]<v[2][j])tut++;
			gec[3][i][2][j]=tut;
		}
	}
	string h="";
	int deg=dpp(0,0,0,0,0);
	if(deg==OYY)deg=-1;
	cout<<deg<<'\n';
	return 0;
}

Compilation message

/tmp/cc2USN7J.o: in function `__tcf_0':
joi2019_ho_t3.cpp:(.text+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc2USN7J.o
/tmp/cc2USN7J.o: in function `dpp(long long, long long, long long, long long, long long)':
joi2019_ho_t3.cpp:(.text._Z3dppxxxxx[_Z3dppxxxxx]+0x18): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc2USN7J.o
joi2019_ho_t3.cpp:(.text._Z3dppxxxxx[_Z3dppxxxxx]+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc2USN7J.o
joi2019_ho_t3.cpp:(.text._Z3dppxxxxx[_Z3dppxxxxx]+0x72): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc2USN7J.o
joi2019_ho_t3.cpp:(.text._Z3dppxxxxx[_Z3dppxxxxx]+0xf2): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc2USN7J.o
joi2019_ho_t3.cpp:(.text._Z3dppxxxxx[_Z3dppxxxxx]+0x133): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc2USN7J.o
joi2019_ho_t3.cpp:(.text._Z3dppxxxxx[_Z3dppxxxxx]+0x13a): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc2USN7J.o
joi2019_ho_t3.cpp:(.text._Z3dppxxxxx[_Z3dppxxxxx]+0x1b4): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc2USN7J.o
joi2019_ho_t3.cpp:(.text._Z3dppxxxxx[_Z3dppxxxxx]+0x213): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc2USN7J.o
joi2019_ho_t3.cpp:(.text._Z3dppxxxxx[_Z3dppxxxxx]+0x21a): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc2USN7J.o
joi2019_ho_t3.cpp:(.text._Z3dppxxxxx[_Z3dppxxxxx]+0x294): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status