이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/********************* بسم الله الرحمن الرحيم ***********************/
/******************** ٱلْحَمْدُ لِلَّٰهِ رَبِّ ٱلْعَالَمِينَ *************************/
/******************* 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],n;
void init(int N,vector<int> h)
{
n=N;
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 p1<v1.size())
{
if (h[v[p]]>h[v1[p1]])
dp[i][v[p]]=min(dp[i][v[p]],dp[i][v1[p1]]+1),p1++;
else
dp[i][v1[p1]]=min(dp[i][v1[p1]],dp[i][v[p]]+1),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)
{
if (n>M)
return c-b;
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;
}
컴파일 시 표준 에러 (stderr) 메시지
jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:52:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | while (p<v.size() and p1<v1.size())
| ~^~~~~~~~~
jumps.cpp:52:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | while (p<v.size() and p1<v1.size())
| ~~^~~~~~~~~~
jumps.cpp:59:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | for (int j=0;j+1<v.size();j++)
| ~~~^~~~~~~~~
jumps.cpp:61:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for (int j=0;j+1<v1.size();j++)
| ~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |