Submission #981293

# Submission time Handle Problem Language Result Execution time Memory
981293 2024-05-13T04:03:57 Z MuhammadSaram Rainforest Jumps (APIO21_jumps) C++17
Compilation error
0 ms 0 KB
/********************* بسم الله الرحمن الرحيم ***********************/
 /******************** ٱلْحَمْدُ لِلَّٰهِ رَبِّ ٱلْعَالَمِينَ *************************/
/******************* Prophet Muhammad صلى الله عليه وسلم ************/
   /*********************** وَقُل رَّبِّ زِدْنِي عِلْمًا **************************/

#ifdef ONLINE_JUDGE
	#pragma GCC optimize("Ofast")
	#pragma GCC optimize("O3,unroll-loops")
	#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#else

#endif

#include <bits/stdc++.h>
#include "jumps.h"
using namespace std;

#define int long long
#define endl '\n'
#define in binary_search
#define ll long long
#define ld long double
#define Hey ios::sync_with_stdio(false);
#define Welcome cin.tie(NULL), cout.tie(NULL);
#define all(v) v.begin(),v.end()

const int inf = 2e5, M = 2000;

int dp[M][M];

void init(int n,int[] h)
{
	if (n>M)
		return;
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			dp[i][j]=(i!=j)*inf;
	for (int i=0;i<n;i++)
	{
		int pre=i;
		vector<int> v,v1;
		for (int j=i+1;j<n;j++)
			if (h[j]>h[pre])
				v.push_back(j),pre=j,dp[i][j]=v.size();
		pre=i;
		for (int j=i-1;j>=0;j--)
			if (h[j]>h[pre])
				v1.push_back(j),pre=j,dp[i][j]=v1.size();
		int p=0,p1=0;
		while (p<v.size() and p2<v1.size())
		{
			if (h[v[p]]>h[v1[p1]])
				dp[i][v[p]]=min(dp[i][v[p]],dp[i][v1[p1]]+dp[v1[p1]][v[p]]),p1++;
			else
				dp[i][v1[p1]]=min(dp[i][v1[p1]],dp[i][v[p]]+dp[v[p]][v1[p1]]),p++;
		}
		for (int j=0;j+1<v.size();j++)
			dp[i][v[j+1]]=min(dp[i][v[j+1]],dp[i][v[j]]+1);
		for (int j=0;j+1<v1.size();j++)
			dp[i][v1[j+1]]=min(dp[i][v1[j+1]],dp[i][v1[j]]+1);
	}
}

int minimum_jumps(int a, int b, int c, int d)
{
	int ans=inf;
	for (int j=c;j<=d;j++)
		for (int i=a;i<=b;i++)
			ans=min(ans,dp[i][j]);
	return ans;
}

Compilation message

jumps.cpp:32:23: error: expected ',' or '...' before 'h'
   32 | void init(int n,int[] h)
      |                       ^
jumps.cpp: In function 'void init(long long int, long long int*)':
jumps.cpp:44:8: error: 'h' was not declared in this scope
   44 |    if (h[j]>h[pre])
      |        ^
jumps.cpp:48:8: error: 'h' was not declared in this scope
   48 |    if (h[j]>h[pre])
      |        ^
jumps.cpp:51:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   while (p<v.size() and p2<v1.size())
      |          ~^~~~~~~~~
jumps.cpp:51:25: error: 'p2' was not declared in this scope; did you mean 'p1'?
   51 |   while (p<v.size() and p2<v1.size())
      |                         ^~
      |                         p1
jumps.cpp:53:8: error: 'h' was not declared in this scope
   53 |    if (h[v[p]]>h[v1[p1]])
      |        ^
jumps.cpp:58:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   for (int j=0;j+1<v.size();j++)
      |                ~~~^~~~~~~~~
jumps.cpp:60:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |   for (int j=0;j+1<v1.size();j++)
      |                ~~~^~~~~~~~~~