이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
map<pair<int,int>,vector<pair<int,int>>> ma;
map<int,vector<int>> at;
map<pair<int,int>,bool> vis;
long long min_distance(std::vector<int> x, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g)
{
	int n=x.size();
	int m=l.size();
	// if(n<=50 and m<=50)
	{
		for(int i=0;i<n;i++)
		{
			at[i].push_back(0);
			at[i].push_back(h[i]);
		}
		for(int j=0;j<m;j++)
		{
			int sb=l[j];
			int eb=r[j];
			int prev=-1;
			for(;sb<=eb;sb++)
			{
				if(h[sb]>=y[j])
				{
					at[sb].push_back(y[j]);
					if(prev!=-1)
					{
						ma[{x[prev],y[j]}].push_back({x[sb],y[j]});
						ma[{x[sb],y[j]}].push_back({x[prev],y[j]});
					}
					prev=sb;
				}
			}
		}
		for(int i=0;i<n;i++)
		{
			sort(begin(at[i]),end(at[i]));
			for(int j=1;j<at[i].size();j++)
			{
				ma[{x[i],at[i][j]}].push_back({x[i],at[i][j-1]});
				ma[{x[i],at[i][j-1]}].push_back({x[i],at[i][j]});
			}
		}
		set<vector<long long>> di;
		di.insert({0,x[s],0});
		while(di.size())
		{
			auto fi=*begin(di);
			di.erase(begin(di));
			if(vis[{fi[1],fi[2]}])
				continue;
			// cout<<"I am "<<fi[0]<<' '<<fi[1]<<' '<<fi[2]<<endl;
			if(fi[1]==x[g] and fi[2]==0)
			{
				return fi[0];
			}
			vis[{fi[1],fi[2]}]=1;
			for(auto [nx,ny]:ma[{fi[1],fi[2]}])
			{
				// cout<<"From "<<fi[1]<<' '<<fi[2]<<" can go to "<<nx<<' '<<ny<<endl;
				di.insert({fi[0]+abs(nx-fi[1])+abs(fi[2]-ny),nx,ny});
			}
		}
	}
	return -1;
}
컴파일 시 표준 에러 (stderr) 메시지
walk.cpp: In function 'long long int min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:43:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |    for(int j=1;j<at[i].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... |